# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53375 | kriii | 즐거운 사진 수집 (JOI13_collecting) | C++17 | 1558 ms | 267180 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |