# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
34032 | 2017-11-06T13:02:09 Z | ToMoClone | 즐거운 사진 수집 (JOI13_collecting) | C++14 | 2716 ms | 181336 KB |
/*input 3 2 0 1 0 2 2 3 0 1 1 2 0 3 */ #include <stdio.h> using namespace std; int n, q, sumr[21][1 << 20], sumc[21][1 << 20], col[1 << 20], row[1 << 20], fullrow[21], fullcol[21]; long long ans = 1; int main(){ scanf("%d%d", &n, &q); for(int i = 0; i <= n; ++i) fullrow[i] = fullcol[i] = (1 << (n - i)); while(q--){ int sign, num; scanf("%d%d", &sign, &num); --num; if(sign == 0){ int val = row[num] ? -1 : 1; row[num] ^= 1; for(int i = 0; i <= n; ++i){ // num -= num & (1 << i); if(sumr[i][num] == 0 || sumr[i][num] == (1 << i)) ans += 4 * fullcol[i], --fullrow[i]; sumr[i][num] += val; if(sumr[i][num] == 0 || sumr[i][num] == (1 << i)) ans -= 4 * fullcol[i], ++fullrow[i]; num -= num & (1 << i); } } if(sign == 1){ int val = col[num] ? -1 : 1; col[num] ^= 1; for(int i = 0; i <= n; ++i){ // num -= num & (1 << i); if(sumc[i][num] == 0 || sumc[i][num] == (1 << i)) ans += 4 * fullrow[i], --fullcol[i]; sumc[i][num] += val; if(sumc[i][num] == 0 || sumc[i][num] == (1 << i)) ans -= 4 * fullrow[i], ++fullcol[i]; num -= num & (1 << i); } } printf("%lld\n", ans); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 181336 KB | Output is correct |
2 | Correct | 0 ms | 181336 KB | Output is correct |
3 | Correct | 0 ms | 181336 KB | Output is correct |
4 | Correct | 0 ms | 181336 KB | Output is correct |
5 | Correct | 0 ms | 181336 KB | Output is correct |
6 | Correct | 0 ms | 181336 KB | Output is correct |
7 | Correct | 0 ms | 181336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 181336 KB | Output is correct |
2 | Correct | 0 ms | 181336 KB | Output is correct |
3 | Correct | 0 ms | 181336 KB | Output is correct |
4 | Correct | 0 ms | 181336 KB | Output is correct |
5 | Correct | 0 ms | 181336 KB | Output is correct |
6 | Correct | 0 ms | 181336 KB | Output is correct |
7 | Correct | 0 ms | 181336 KB | Output is correct |
8 | Correct | 0 ms | 181336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2716 ms | 181336 KB | Output is correct |
2 | Correct | 2513 ms | 181336 KB | Output is correct |
3 | Correct | 2239 ms | 181336 KB | Output is correct |
4 | Correct | 2376 ms | 181336 KB | Output is correct |
5 | Correct | 2286 ms | 181336 KB | Output is correct |
6 | Correct | 2276 ms | 181336 KB | Output is correct |
7 | Correct | 2363 ms | 181336 KB | Output is correct |
8 | Correct | 2363 ms | 181336 KB | Output is correct |
9 | Correct | 1996 ms | 181336 KB | Output is correct |
10 | Correct | 2033 ms | 181336 KB | Output is correct |
11 | Correct | 2289 ms | 181336 KB | Output is correct |
12 | Correct | 2169 ms | 181336 KB | Output is correct |
13 | Correct | 2159 ms | 181336 KB | Output is correct |