Submission #204140

#TimeUsernameProblemLanguageResultExecution timeMemory
204140nubboiiiiiCoin Collecting (JOI19_ho_t4)C++14
0 / 100
7 ms2684 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define forinc(i,a,b) for(int i=a;i<=b;++i) #define fordec(i,a,b) for(int i=a;i>=b;--i) #define forv(i,x) for(auto &i:x) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r) { return l+rng()%(r-l+1); } #define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;}) #define pii pair<int,int> #define fi first #define se second #define batbit(i,x) (x|(1ll<<i)) #define getbit(i,x) ((x>>i)&1) const int mn=1e5+10; int cnt[mn][3],n,kq; main() { //freopen("test.inp","r",stdin); memset(cnt,-1,sizeof cnt); cin >> n; forinc(i,1,2*n) { int x,y; cin >> x >> y; if(x>=1&&x<=n) { if(y<=1) { cnt[x][1]++; kq+=abs(1-y); } else { cnt[x][2]++; kq+=abs(y-2); } } else { if(x<1) { if(y<=1) { cnt[1][1]++; kq+=abs(1-y)+abs(1-x); } else { cnt[1][2]++; kq+=abs(y-2)+abs(1-x); } } else { if(y<=1) { cnt[n][1]++; kq+=abs(1-y)+abs(x-n); } else { cnt[n][2]++; kq+=abs(y-2)+abs(x-n); } } } } cnt[0][1]=cnt[0][2]=0; forinc(i,1,n) { forinc(j,1,2) { cnt[i][j]+=cnt[i-1][j]; kq+=abs(cnt[i-1][j]); } if(cnt[i][1]*cnt[i][2]<0) { cnt[i][1]+=cnt[i][2]; kq+=abs(cnt[i][2]); cnt[i][2]=0; } } cout << kq; } /* 0 0 -1 kq=0; 1 0 0 0 0 -1 kq=1 1 1 0 0 0 -1 kq=2; 1 1 1 */

Compilation message (stderr)

joi2019_ho_t4.cpp:22:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...