# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
43198 | 2018-03-10T14:29:45 Z | baactree | 즐거운 사진 수집 (JOI13_collecting) | C++14 | 2528 ms | 44520 KB |
#include <bits/stdc++.h> using namespace std; int n, q; int r[21], c[21]; int ro[1 << 20], co[1 << 20]; int rs[21][1 << 20], cs[21][1 << 20]; int main() { scanf("%d%d", &n, &q); long long cnt = 0; for (int i = 1; i <= n; i++) r[i] = c[i] = 1 << (n - i); while (q--) { int a, b; scanf("%d%d", &a, &b); b--; if (a) { //col for (int i = 1, d = 2; i <= n; i++,d<<=1) { int pre = rs[i][b / d]; int now = 0; if (pre == 0)now = 1; else if (pre == d)now = d - 1; else if (co[b])now = pre - 1; else now = pre + 1; rs[i][b / d] = now; pre %= d; now %= d; if (!pre)c[i]--; if (!now)c[i]++; long long k = 0; if (pre == 0)k = 1; else if (now == 0)k = -1; cnt += r[i] * k; } co[b] ^= 1; } else { //col for (int i = 1, d = 2; i <= n; i++, d <<= 1) { int pre = cs[i][b / d]; int now = 0; if (pre == 0)now = 1; else if (pre == d)now = d - 1; else if (ro[b])now = pre - 1; else now = pre + 1; cs[i][b / d] = now; pre %= d; now %= d; if (!pre)r[i]--; if (!now)r[i]++; long long k = 0; if (pre == 0)k = 1; else if (now == 0)k = -1; cnt += c[i] * k; } ro[b] ^= 1; } printf("%lld\n", cnt * 4 + 1); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 1 ms | 480 KB | Output is correct |
3 | Correct | 1 ms | 656 KB | Output is correct |
4 | Correct | 1 ms | 656 KB | Output is correct |
5 | Correct | 2 ms | 752 KB | Output is correct |
6 | Correct | 1 ms | 752 KB | Output is correct |
7 | Correct | 2 ms | 752 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 752 KB | Output is correct |
2 | Correct | 3 ms | 752 KB | Output is correct |
3 | Correct | 2 ms | 764 KB | Output is correct |
4 | Correct | 3 ms | 780 KB | Output is correct |
5 | Correct | 3 ms | 796 KB | Output is correct |
6 | Correct | 3 ms | 812 KB | Output is correct |
7 | Correct | 2 ms | 812 KB | Output is correct |
8 | Correct | 3 ms | 812 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1993 ms | 44136 KB | Output is correct |
2 | Correct | 1979 ms | 44188 KB | Output is correct |
3 | Correct | 1788 ms | 44188 KB | Output is correct |
4 | Correct | 2035 ms | 44520 KB | Output is correct |
5 | Correct | 2528 ms | 44520 KB | Output is correct |
6 | Correct | 2261 ms | 44520 KB | Output is correct |
7 | Correct | 2261 ms | 44520 KB | Output is correct |
8 | Correct | 2230 ms | 44520 KB | Output is correct |
9 | Correct | 1900 ms | 44520 KB | Output is correct |
10 | Correct | 1972 ms | 44520 KB | Output is correct |
11 | Correct | 1982 ms | 44520 KB | Output is correct |
12 | Correct | 2118 ms | 44520 KB | Output is correct |
13 | Correct | 1873 ms | 44520 KB | Output is correct |