Submission #53375

#TimeUsernameProblemLanguageResultExecution timeMemory
53375kriii즐거운 사진 수집 (JOI13_collecting)C++17
100 / 100
1558 ms267180 KiB
#include <stdio.h> const int Z = 1<<20; int N,M,B[2][Z*2]; long long base,C[2][20]; void in(int k, int x) { x += Z; B[k][x] = 3 - B[k][x]; x /= 2; int l = 0; while (x){ if (B[k][x] != 3) C[k][l]--; B[k][x] = B[k][x*2] | B[k][x*2+1]; if (B[k][x] != 3) C[k][l]++; x /= 2; l++; } } int main() { scanf ("%d %d",&N,&M); for (int i=0;i<=N;i++) base += 1ll << (2 * i); for (int k=0;k<2;k++){ for (int i=0;i<Z*2;i++) B[k][i] = 1; for (int i=0;i<N;i++) C[k][i] = (1 << (N - i - 1)); } while (M--){ int k,x; scanf ("%d %d",&k,&x); x--; in(k,x); long long ans = base; for (int i=0;i<N;i++) ans -= C[0][i] * C[1][i] * 4; printf ("%lld\n",ans); } return 0; }

Compilation message (stderr)

collecting.cpp: In function 'int main()':
collecting.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d %d",&N,&M);
  ~~~~~~^~~~~~~~~~~~~~~
collecting.cpp:31:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int k,x; scanf ("%d %d",&k,&x); x--;
            ~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...