Submission #74112463
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
#define INF 1e18
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl "\n"
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define mii map<int, int>
#define seti set<int>
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i = a; i < b; i++)
#define pr(a) cout<<a<<endl;
#define printList(a) for (auto &x : a) cout << x << " ";cout<<endl;
#define printMap(a) for (auto &x : a) cout << x.ff << " " << x.ss << endl;
#define PI 3.1415926535897932384626
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define w(x) int x; cin>>x; while(x--)
#define sortall(x) sort(all(x))
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vpii vector<pii>
#define matrix(N,M) vvi matrix(N, vi(M, 0));
#define printMatrix(matrix) for(auto &x:matrix){for(auto &y:x)cout<<y<<" ";cout<<endl;}
#define inputMatrix(matrix) for(auto &x:matrix)for(auto &y:x)cin>>y;
#define sortMatrix(matrix) for(auto &x:matrix)sortall(x);
#define rotateMatrix(matrix) reverse(all(matrix));for(int i=0;i<matrix.size();i++)for(int j=0;j<i;j++)swap(matrix[i][j],matrix[j][i]);
#define matrixSum(matrix) int sum=0;for(auto &x:matrix)for(auto &y:x)sum+=y;cout<<sum<<endl;
#define matrixProduct(matrix) int product=1;for(auto &x:matrix)for(auto &y:x)product*=y;cout<<product<<endl;
#define matrixMax(matrix) int mx=INT_MIN;for(auto &x:matrix)for(auto &y:x)mx=max(mx,y);cout<<mx<<endl;
#define matrixMin(matrix) int mn=INT_MAX;for(auto &x:matrix)for(auto &y:x)mn=min(mn,y);cout<<mn<<endl;
#define matrixTranspose(matrix) for(int i=0;i<matrix.size();i++)for(int j=0;j<i;j++)swap(matrix[i][j],matrix[j][i]);
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define maxEle(a) *max_element(all(a))
#define minEle(a) *min_element(all(a))
#define sumEle(a) accumulate(all(a),0)
#define productEle(a) accumulate(all(a),1,multiplies<int>())
#define maxIndex(a) max_element(all(a))-a.begin()
#define minIndex(a) min_element(all(a))-a.begin()
#define findIndex(a,x) find(all(a),x)-a.begin()
#define findEle(a,x) find(all(a),x)!=a.end()
#define countEle(a,x) count(all(a),x)
#define lowerEle(a,x) lower_bound(all(a),x)-a.begin()
#define upperEle(a,x) upper_bound(all(a),x)-a.begin()
#define gcd(a,b) __gcd(a,b)
#define hi cout<<"Hello\n";
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
int Binary_exp(int a, int b, int c ){
int ans = 1;
while(b){
if(b&1){
ans =(ans*1LL*a) % c;
}
a = (a*1LL*a) % c;
b/=2;
}
return ans;
}
int C(int n, int r) { if (r > n - r) r = n - r; int ans = 1; for (int i = 1; i <= r; i++) { ans *= n - r + i; ans /= i; } return ans; }
int modInv(int a) { return Binary_exp(a, MOD - 2, MOD); }
bool isPrime(int n){ if(n<=1)return false; for(int i=2;i*i<=n;i++)if(n%i==0)return false; return true; }
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){for(auto &it:p)os<<it<<' ';return os;}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<endl;}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
int count(int X, int Y) {
if (X < 0 || Y < 0) return 0;
int tot = 0;
for (int x = 0; x <= X; ++x) {
if (x % 2 == 0) {
tot += (x + 1);
if (Y > x) {
int start = x + 1;
int end = Y;
if (start <= end) {
int ev = (end / 2) - ((start - 1) / 2);
tot += ev;
}
}
} else {
if (Y > x) {
int start = x + 1;
int end = Y;
if (start <= end) {
int ev = (end / 2) - ((start - 1) / 2);
tot += ev;
}
}
}
}
return tot;
}
int check(int X, int Y) {
if (X >= 0 && Y >= 0) return count(X, Y);
if (X < 0 && Y >= 0) return count(-X, Y) - count(0, Y);
if (X >= 0 && Y < 0) return count(X, -Y) - count(X, 0);
if (X < 0 && Y < 0) return count(-X, -Y) - count(0, -Y) - count(-X, 0) + count(0, 0);
return 0;
}
void solved(){
int L, R, D, U;
cin >> L >> R >> D >> U ;
auto find = [&](int x, int y) {
int cnt = 0;
for (int x = L; x <= R; ++x) {
int absx = abs(x);
int low = max(D, -absx);
int upp = min(U, absx);
if (low <= upp && absx % 2 == 0) {
cnt += (upp - low + 1);
}
int r = max(D, absx + 1);
int r1 = U;
if (r <= r1) {
cnt += (r1 / 2) - ((r - 1) / 2);
if (r <= 0 && r1 >= 0){
//0
}
}
int r2 = D;
int rr2 = min(U, -absx - 1);
if (r2 <= rr2) {
int L_pos = -rr2;
int R_pos = -r2;
cnt += (R_pos / 2) - ((L_pos - 1) / 2);
}
}
return cnt;
};
cout << find(R, U) << endl;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
//cin>>t;
while(t--){
solved();
}
return 0;
}
Submission Info
| Submission Time |
|
| Task |
D - Make Target 2 |
| User |
s_mtCF |
| Language |
C++23 (GCC 15.2.0) |
| Score |
425 |
| Code Size |
5793 Byte |
| Status |
AC |
| Exec Time |
7 ms |
| Memory |
3728 KiB |
Compile Error
./Main.cpp: In lambda function:
./Main.cpp:122:25: warning: unused parameter 'x' [-Wunused-parameter]
122 | auto find = [&](int x, int y) {
| ^
./Main.cpp:122:32: warning: unused parameter 'y' [-Wunused-parameter]
122 | auto find = [&](int x, int y) {
| ^
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
425 / 425 |
| Status |
|
|
| 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 |
2 ms |
3568 KiB |
| sample01.txt |
AC |
1 ms |
3548 KiB |
| testcase00.txt |
AC |
7 ms |
3592 KiB |
| testcase01.txt |
AC |
7 ms |
3548 KiB |
| testcase02.txt |
AC |
1 ms |
3532 KiB |
| testcase03.txt |
AC |
2 ms |
3584 KiB |
| testcase04.txt |
AC |
2 ms |
3472 KiB |
| testcase05.txt |
AC |
2 ms |
3524 KiB |
| testcase06.txt |
AC |
1 ms |
3688 KiB |
| testcase07.txt |
AC |
3 ms |
3484 KiB |
| testcase08.txt |
AC |
1 ms |
3544 KiB |
| testcase09.txt |
AC |
1 ms |
3484 KiB |
| testcase10.txt |
AC |
2 ms |
3536 KiB |
| testcase11.txt |
AC |
3 ms |
3688 KiB |
| testcase12.txt |
AC |
1 ms |
3688 KiB |
| testcase13.txt |
AC |
1 ms |
3476 KiB |
| testcase14.txt |
AC |
1 ms |
3596 KiB |
| testcase15.txt |
AC |
2 ms |
3532 KiB |
| testcase16.txt |
AC |
3 ms |
3584 KiB |
| testcase17.txt |
AC |
1 ms |
3636 KiB |
| testcase18.txt |
AC |
1 ms |
3484 KiB |
| testcase19.txt |
AC |
2 ms |
3476 KiB |
| testcase20.txt |
AC |
2 ms |
3728 KiB |
| testcase21.txt |
AC |
1 ms |
3592 KiB |
| testcase22.txt |
AC |
1 ms |
3676 KiB |
| testcase23.txt |
AC |
1 ms |
3476 KiB |
| testcase24.txt |
AC |
1 ms |
3564 KiB |
| testcase25.txt |
AC |
1 ms |
3544 KiB |
| testcase26.txt |
AC |
1 ms |
3476 KiB |