Submission #43205

# Submission time Handle Problem Language Result Execution time Memory
43205 2018-03-10T15:03:05 Z baactree 즐거운 사진 수집 (JOI13_collecting) C++14
100 / 100
2142 ms 44488 KB
#include <bits/stdc++.h>
using namespace std;
int n, q;
int w[2][21], o[2][1 << 20], s[2][21][1 << 20];
int main() {
	scanf("%d%d", &n, &q);
	long long cnt = 0;
	for (int i = 1; i <= n; i++)w[0][i] = w[1][i] = 1 << (n - i);
	while (q--) {
		int a, b;
		scanf("%d%d", &a, &b);b--;
		for (int i = 1, d = 2,k=0; i <= n;cnt+=w[!a][i]*k, i++, d <<= 1,k=0) {
			if (!(s[a][i][b / d] % d))w[a][i]--, k = 1;
			s[a][i][b / d] += o[a][b] ? -1 : 1;
			if (!(s[a][i][b / d] % d))w[a][i]++, k = -1;
		}
		o[a][b] ^= 1;
		printf("%lld\n", cnt * 4 + 1);
	}
	return 0;
}

Compilation message

collecting.cpp: In function 'int main()':
collecting.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &q);
                       ^
collecting.cpp:11:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a, &b);b--;
                        ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 568 KB Output is correct
5 Correct 2 ms 752 KB Output is correct
6 Correct 2 ms 752 KB Output is correct
7 Correct 2 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 752 KB Output is correct
2 Correct 3 ms 752 KB Output is correct
3 Correct 3 ms 752 KB Output is correct
4 Correct 3 ms 752 KB Output is correct
5 Correct 3 ms 752 KB Output is correct
6 Correct 3 ms 752 KB Output is correct
7 Correct 3 ms 864 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1989 ms 44252 KB Output is correct
2 Correct 2066 ms 44252 KB Output is correct
3 Correct 1757 ms 44252 KB Output is correct
4 Correct 1964 ms 44488 KB Output is correct
5 Correct 2098 ms 44488 KB Output is correct
6 Correct 1913 ms 44488 KB Output is correct
7 Correct 2142 ms 44488 KB Output is correct
8 Correct 1932 ms 44488 KB Output is correct
9 Correct 1691 ms 44488 KB Output is correct
10 Correct 1738 ms 44488 KB Output is correct
11 Correct 1916 ms 44488 KB Output is correct
12 Correct 1984 ms 44488 KB Output is correct
13 Correct 1724 ms 44488 KB Output is correct