# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133249 | dantoh000 | 즐거운 사진 수집 (JOI13_collecting) | C++14 | 1536 ms | 61944 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 <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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |