| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 525456 | rainboy | 즐거운 사진 수집 (JOI13_collecting) | C11 | 1143 ms | 61900 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>
#define H_ 20
#define N_ (1 << H_)
int h_, n_;
void pul(int *st, int *kk, int i, int h) {
int l = i << 1, r = l | 1;
if (st[i] != -1)
kk[h]--;
st[i] = st[l] == -1 || st[r] == -1 || st[l] != st[r] ? -1 : st[l];
if (st[i] != -1)
kk[h]++;
}
void update(int *st, int *kk, int i) {
int h;
i += n_;
st[i] ^= 1;
for (h = 1; h <= h_; h++)
pul(st, kk, i >> h, h);
}
int main() {
static int st1[N_ * 2], st2[N_ * 2], kk1[H_ + 1], kk2[H_ + 1];
int q, h;
scanf("%d%d", &h_, &q), n_ = 1 << h_;
for (h = 0; h <= h_; h++)
kk1[h] = kk2[h] = n_ >> h;
while (q--) {
int t, h, i, j;
long long ans;
scanf("%d", &t);
if (t == 0) {
scanf("%d", &i), i--;
update(st1, kk1, i);
} else {
scanf("%d", &j), j--;
update(st2, kk2, j);
}
ans = 0;
for (h = 0; h <= h_; h++)
ans += (long long) (n_ >> h) * (n_ >> h) - (long long) kk1[h] * kk2[h];
ans = ans * 4 + 1;
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... | ||||
