Submission #74099360


Source Code Expand

// Problem: D - Make Target 2
// Contest: AtCoder - AtCoder Beginner Contest 449
// URL: https://atcoder.jp/contests/abc449/tasks/abc449_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//空中散歩の SOS 僕ファー 僕ファー 僕ファー ~
#include<bits/stdc++.h>
using namespace std;
// --- Types ---
using ll = long long;
using db = double; 
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using poly = vi;

// --- Macros ---
#define fi first
#define se second
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unq(v) (v).erase(unique(all(v)), (v).end())

// --- Loops ---
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
#define fore(x, a) for(auto& x : a)

// --- Utils ---
template<class T> bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll calc(ll xx,ll xy,ll yx,ll yy,ll L,ll R,ll D,ll U){
	ll len1=0;
	ll l=max(xx,L),r=min(xy,R);
	if(l<=r)len1=r-l+1;
	ll len2=0;
	l=max(yx,D),r=min(yy,U);
	if(l<=r)len2=r-l+1;
	return len1*len2;
}

void solve(){
	ll L,R,D,U;
	cin>>L>>R>>D>>U;
	ll ans=0;
	per(i,1000000,0){
		ll del=calc(-i,i,-i,i,L,R,D,U);
		if(i&1)ans-=del;
		else ans+=del;
	}
	cout<<ans<<endl;
	return ;
}
ll T=1;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	cin>>T;
	for(ll kase=1;kase<=T;kase++){
		solve();
	}
	return 0;
}

Submission Info

Submission Time
Task D - Make Target 2
User XING_ginkiha
Language C++23 (GCC 15.2.0)
Score 425
Code Size 1765 Byte
Status AC
Exec Time 3 ms
Memory 3672 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 2
AC × 29
Set Name Test Cases
Sample sample00.txt, sample01.txt
All sample00.txt, sample01.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt
Case Name Status Exec Time Memory
sample00.txt AC 3 ms 3552 KiB
sample01.txt AC 2 ms 3552 KiB
testcase00.txt AC 2 ms 3448 KiB
testcase01.txt AC 2 ms 3552 KiB
testcase02.txt AC 2 ms 3448 KiB
testcase03.txt AC 2 ms 3640 KiB
testcase04.txt AC 2 ms 3552 KiB
testcase05.txt AC 2 ms 3552 KiB
testcase06.txt AC 2 ms 3552 KiB
testcase07.txt AC 2 ms 3448 KiB
testcase08.txt AC 2 ms 3440 KiB
testcase09.txt AC 2 ms 3596 KiB
testcase10.txt AC 2 ms 3560 KiB
testcase11.txt AC 2 ms 3552 KiB
testcase12.txt AC 2 ms 3532 KiB
testcase13.txt AC 2 ms 3672 KiB
testcase14.txt AC 3 ms 3580 KiB
testcase15.txt AC 2 ms 3608 KiB
testcase16.txt AC 2 ms 3512 KiB
testcase17.txt AC 2 ms 3512 KiB
testcase18.txt AC 2 ms 3448 KiB
testcase19.txt AC 3 ms 3432 KiB
testcase20.txt AC 2 ms 3560 KiB
testcase21.txt AC 3 ms 3432 KiB
testcase22.txt AC 2 ms 3612 KiB
testcase23.txt AC 2 ms 3612 KiB
testcase24.txt AC 2 ms 3556 KiB
testcase25.txt AC 2 ms 3500 KiB
testcase26.txt AC 2 ms 3472 KiB