Submission #133249

#TimeUsernameProblemLanguageResultExecution timeMemory
133249dantoh000즐거운 사진 수집 (JOI13_collecting)C++14
100 / 100
1536 ms61944 KiB
#include <bits/stdc++.h> using namespace std; int n,q; struct node{ int h; vector<int> a; vector<int> ct; node(int _h){ h = _h; a = vector<int>((1<<(n+1))+1,0); ct = vector<int>(n+1,0); } void up(int x){ int cur = n-1; x += (1<<n)-1; a[x] ^= 1; x >>= 1; while (x){ if (a[x] == 2) ct[cur]--; //printf("%d depends %d %d\n",x,a[x<<1],a[(x<<1)+1]); if (a[x<<1] == a[(x<<1) + 1]) a[x] = a[x<<1]; else a[x] = 2; if (a[x] == 2) ct[cur]++; x >>= 1; cur--; } } }*rx, *ry; int main(){ scanf("%d%d",&n,&q); rx = new node(n), ry = new node(n); for (int i = 0; i < q; i++){ int a, b; scanf("%d%d",&a,&b); if (a == 0){ rx->up(b); } else ry->up(b); long long ans = 0; for (int i = 0; i < n; i++){ //printf("size %d %lld\n",i,-1ll*rx->ct[i]*ry->ct[i]+(1ll<<i)*(rx->ct[i]+ry->ct[i])); ans -= 1ll*rx->ct[i]*ry->ct[i]-(1ll<<i)*(rx->ct[i]+ry->ct[i]); } printf("%lld\n",(ans<<2) + 1); } }

Compilation message (stderr)

collecting.cpp: In function 'int main()':
collecting.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&q);
     ~~~~~^~~~~~~~~~~~~~
collecting.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&a,&b);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...