# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
60731 | 2018-07-24T15:37:51 Z | gusfring | Snake Escaping (JOI18_snake_escaping) | C++14 | 694 ms | 66560 KB |
#include <stdio.h> int L,Q; char sc[1<<15+2]; int bc[1<<15]; int Z[1<<15],O[1<<15]; void go(int l, int r) { if (l+1 == r) return; int m = (l + r) / 2; go(l,m); go(m,r); for (int i=l;i<m;i++){ Z[i-l+m] += Z[i]; O[i] += O[i-l+m]; } } int main() { scanf ("%d %d",&L,&Q); scanf ("%s",sc); for (int i=0;i<(1<<L);i++){ if (i) bc[i] = bc[i-(i&(-i))] + 1; Z[i] = O[i] = sc[i] - '0'; } go(0,(1<<L)); while (Q--){ char q[22]; scanf ("%s",q); int z = 0, o = 0, f = 0; for (int i=0;i<L;i++){ if (q[i] == '0') z |= 1 << (L - i - 1); if (q[i] == '1') o |= 1 << (L - i - 1); if (q[i] == '?') f |= 1 << (L - i - 1); } int ans = 0; if (bc[f] <= 7){ for (int x=f;;x=(x-1)&f){ ans += sc[x|o] - '0'; if (!x) break; } } else if (bc[o] <= 7){ for (int x=o;;x=(x-1)&o){ int b = f + x; if (bc[o] % 2 != bc[x] % 2) ans -= Z[b]; else ans += Z[b]; if (!x) break; } } else{ for (int x=z;;x=(x-1)&z){ int b = o + z - x; if (bc[z] % 2 != bc[x] % 2) ans -= O[b]; else ans += O[b]; if (!x) break; } } printf ("%d\n",ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 368 KB | Output is correct |
3 | Correct | 3 ms | 456 KB | Output is correct |
4 | Correct | 3 ms | 596 KB | Output is correct |
5 | Correct | 4 ms | 596 KB | Output is correct |
6 | Correct | 4 ms | 600 KB | Output is correct |
7 | Correct | 4 ms | 692 KB | Output is correct |
8 | Correct | 3 ms | 700 KB | Output is correct |
9 | Correct | 3 ms | 716 KB | Output is correct |
10 | Correct | 3 ms | 728 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 368 KB | Output is correct |
3 | Correct | 3 ms | 456 KB | Output is correct |
4 | Correct | 3 ms | 596 KB | Output is correct |
5 | Correct | 4 ms | 596 KB | Output is correct |
6 | Correct | 4 ms | 600 KB | Output is correct |
7 | Correct | 4 ms | 692 KB | Output is correct |
8 | Correct | 3 ms | 700 KB | Output is correct |
9 | Correct | 3 ms | 716 KB | Output is correct |
10 | Correct | 3 ms | 728 KB | Output is correct |
11 | Correct | 381 ms | 6700 KB | Output is correct |
12 | Correct | 488 ms | 6700 KB | Output is correct |
13 | Correct | 468 ms | 6700 KB | Output is correct |
14 | Correct | 399 ms | 6700 KB | Output is correct |
15 | Correct | 470 ms | 6728 KB | Output is correct |
16 | Correct | 370 ms | 6728 KB | Output is correct |
17 | Correct | 443 ms | 14748 KB | Output is correct |
18 | Correct | 298 ms | 16516 KB | Output is correct |
19 | Correct | 401 ms | 16516 KB | Output is correct |
20 | Correct | 487 ms | 16516 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 368 KB | Output is correct |
3 | Correct | 3 ms | 456 KB | Output is correct |
4 | Correct | 3 ms | 596 KB | Output is correct |
5 | Correct | 4 ms | 596 KB | Output is correct |
6 | Correct | 4 ms | 600 KB | Output is correct |
7 | Correct | 4 ms | 692 KB | Output is correct |
8 | Correct | 3 ms | 700 KB | Output is correct |
9 | Correct | 3 ms | 716 KB | Output is correct |
10 | Correct | 3 ms | 728 KB | Output is correct |
11 | Correct | 381 ms | 6700 KB | Output is correct |
12 | Correct | 488 ms | 6700 KB | Output is correct |
13 | Correct | 468 ms | 6700 KB | Output is correct |
14 | Correct | 399 ms | 6700 KB | Output is correct |
15 | Correct | 470 ms | 6728 KB | Output is correct |
16 | Correct | 370 ms | 6728 KB | Output is correct |
17 | Correct | 443 ms | 14748 KB | Output is correct |
18 | Correct | 298 ms | 16516 KB | Output is correct |
19 | Correct | 401 ms | 16516 KB | Output is correct |
20 | Correct | 487 ms | 16516 KB | Output is correct |
21 | Correct | 586 ms | 16516 KB | Output is correct |
22 | Correct | 615 ms | 16516 KB | Output is correct |
23 | Correct | 567 ms | 28488 KB | Output is correct |
24 | Correct | 503 ms | 42096 KB | Output is correct |
25 | Correct | 531 ms | 57612 KB | Output is correct |
26 | Runtime error | 694 ms | 66560 KB | Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
27 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 368 KB | Output is correct |
3 | Correct | 3 ms | 456 KB | Output is correct |
4 | Correct | 3 ms | 596 KB | Output is correct |
5 | Correct | 4 ms | 596 KB | Output is correct |
6 | Correct | 4 ms | 600 KB | Output is correct |
7 | Correct | 4 ms | 692 KB | Output is correct |
8 | Correct | 3 ms | 700 KB | Output is correct |
9 | Correct | 3 ms | 716 KB | Output is correct |
10 | Correct | 3 ms | 728 KB | Output is correct |
11 | Runtime error | 4 ms | 66560 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 368 KB | Output is correct |
3 | Correct | 3 ms | 456 KB | Output is correct |
4 | Correct | 3 ms | 596 KB | Output is correct |
5 | Correct | 4 ms | 596 KB | Output is correct |
6 | Correct | 4 ms | 600 KB | Output is correct |
7 | Correct | 4 ms | 692 KB | Output is correct |
8 | Correct | 3 ms | 700 KB | Output is correct |
9 | Correct | 3 ms | 716 KB | Output is correct |
10 | Correct | 3 ms | 728 KB | Output is correct |
11 | Correct | 381 ms | 6700 KB | Output is correct |
12 | Correct | 488 ms | 6700 KB | Output is correct |
13 | Correct | 468 ms | 6700 KB | Output is correct |
14 | Correct | 399 ms | 6700 KB | Output is correct |
15 | Correct | 470 ms | 6728 KB | Output is correct |
16 | Correct | 370 ms | 6728 KB | Output is correct |
17 | Correct | 443 ms | 14748 KB | Output is correct |
18 | Correct | 298 ms | 16516 KB | Output is correct |
19 | Correct | 401 ms | 16516 KB | Output is correct |
20 | Correct | 487 ms | 16516 KB | Output is correct |
21 | Correct | 586 ms | 16516 KB | Output is correct |
22 | Correct | 615 ms | 16516 KB | Output is correct |
23 | Correct | 567 ms | 28488 KB | Output is correct |
24 | Correct | 503 ms | 42096 KB | Output is correct |
25 | Correct | 531 ms | 57612 KB | Output is correct |
26 | Runtime error | 694 ms | 66560 KB | Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
27 | Halted | 0 ms | 0 KB | - |