# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
125702 | 2019-07-06T09:04:05 Z | 김세빈(#3068) | Snake Escaping (JOI18_snake_escaping) | C++14 | 2000 ms | 14816 KB |
#include <bits/stdc++.h> using namespace std; char S[1101010]; int D1[1101010], D2[1101010]; int n, q; int main() { vector <int> X; int i, j, v, s, x, ans; scanf("%d%d%s", &n, &q, S); for(i=0; i<(1<<n); i++){ D1[i] = D2[i] = S[i] - '0'; } for(i=0; i<n; i++){ for(j=0; j<(1<<n); j++){ if(j & (1 << i)){ D1[j] += D1[j - (1 << i)]; } } } for(; q--; ){ scanf("%s", S); reverse(S, S + n); for(i=0, s=0; i<n; i++){ if(S[i] == '?') s ++; } X.clear(); ans = 0; v = 0; if(s >= 10){ for(i=0; i<n; i++){ if(S[i] == '1') v += 1 << i, X.push_back(i); else if(S[i] == '?') v += 1 << i; } s = X.size(); x = 1; for(i=0; i<(1<<s); i++){ ans += D1[v] * x; for(j=0; (2<<j)<(i^i+1); j++){ v += 1 << X[j]; x = -x; } if(j < s) v -= 1 << X[j], x = -x; } } else{ for(i=0; i<n; i++){ if(S[i] == '?') X.push_back(i); else v += S[i] - '0' << i; } s = X.size(); for(i=0; i<(1<<s); i++){ ans += D2[v]; for(j=0; (2<<j)<(i^i+1); j++){ v -= 1 << X[j]; } if(j < s) v += 1 << X[j]; } } printf("%d\n", ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 380 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 380 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 468 ms | 4312 KB | Output is correct |
12 | Correct | 616 ms | 4216 KB | Output is correct |
13 | Correct | 319 ms | 3192 KB | Output is correct |
14 | Correct | 313 ms | 3352 KB | Output is correct |
15 | Correct | 622 ms | 4376 KB | Output is correct |
16 | Correct | 392 ms | 3704 KB | Output is correct |
17 | Correct | 395 ms | 3576 KB | Output is correct |
18 | Correct | 245 ms | 5624 KB | Output is correct |
19 | Correct | 237 ms | 7416 KB | Output is correct |
20 | Correct | 609 ms | 9204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 380 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 468 ms | 4312 KB | Output is correct |
12 | Correct | 616 ms | 4216 KB | Output is correct |
13 | Correct | 319 ms | 3192 KB | Output is correct |
14 | Correct | 313 ms | 3352 KB | Output is correct |
15 | Correct | 622 ms | 4376 KB | Output is correct |
16 | Correct | 392 ms | 3704 KB | Output is correct |
17 | Correct | 395 ms | 3576 KB | Output is correct |
18 | Correct | 245 ms | 5624 KB | Output is correct |
19 | Correct | 237 ms | 7416 KB | Output is correct |
20 | Correct | 609 ms | 9204 KB | Output is correct |
21 | Correct | 1016 ms | 9048 KB | Output is correct |
22 | Correct | 1038 ms | 9528 KB | Output is correct |
23 | Correct | 440 ms | 8268 KB | Output is correct |
24 | Correct | 422 ms | 8184 KB | Output is correct |
25 | Correct | 1624 ms | 10260 KB | Output is correct |
26 | Correct | 565 ms | 8672 KB | Output is correct |
27 | Correct | 574 ms | 8668 KB | Output is correct |
28 | Correct | 275 ms | 11128 KB | Output is correct |
29 | Correct | 267 ms | 7156 KB | Output is correct |
30 | Correct | 1069 ms | 9176 KB | Output is correct |
31 | Correct | 708 ms | 9164 KB | Output is correct |
32 | Correct | 534 ms | 9224 KB | Output is correct |
33 | Correct | 370 ms | 7928 KB | Output is correct |
34 | Correct | 423 ms | 8184 KB | Output is correct |
35 | Correct | 571 ms | 8488 KB | Output is correct |
36 | Correct | 258 ms | 7096 KB | Output is correct |
37 | Correct | 701 ms | 9068 KB | Output is correct |
38 | Correct | 277 ms | 7120 KB | Output is correct |
39 | Correct | 443 ms | 8368 KB | Output is correct |
40 | Correct | 422 ms | 8028 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 380 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 369 ms | 9904 KB | Output is correct |
12 | Correct | 94 ms | 9848 KB | Output is correct |
13 | Correct | 79 ms | 11768 KB | Output is correct |
14 | Correct | 101 ms | 11848 KB | Output is correct |
15 | Correct | 64 ms | 11896 KB | Output is correct |
16 | Correct | 107 ms | 11768 KB | Output is correct |
17 | Correct | 108 ms | 11768 KB | Output is correct |
18 | Correct | 57 ms | 12024 KB | Output is correct |
19 | Correct | 57 ms | 11640 KB | Output is correct |
20 | Correct | 197 ms | 11960 KB | Output is correct |
21 | Correct | 80 ms | 11884 KB | Output is correct |
22 | Correct | 99 ms | 11836 KB | Output is correct |
23 | Correct | 64 ms | 11768 KB | Output is correct |
24 | Correct | 83 ms | 11772 KB | Output is correct |
25 | Correct | 105 ms | 11896 KB | Output is correct |
26 | Correct | 54 ms | 11768 KB | Output is correct |
27 | Correct | 56 ms | 11896 KB | Output is correct |
28 | Correct | 58 ms | 11640 KB | Output is correct |
29 | Correct | 79 ms | 11768 KB | Output is correct |
30 | Correct | 81 ms | 11772 KB | Output is correct |
31 | Correct | 64 ms | 11800 KB | Output is correct |
32 | Correct | 114 ms | 11844 KB | Output is correct |
33 | Correct | 103 ms | 11824 KB | Output is correct |
34 | Correct | 54 ms | 11668 KB | Output is correct |
35 | Correct | 108 ms | 11768 KB | Output is correct |
36 | Correct | 108 ms | 11868 KB | Output is correct |
37 | Correct | 106 ms | 11896 KB | Output is correct |
38 | Correct | 116 ms | 11868 KB | Output is correct |
39 | Correct | 113 ms | 11896 KB | Output is correct |
40 | Correct | 112 ms | 11804 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 380 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 468 ms | 4312 KB | Output is correct |
12 | Correct | 616 ms | 4216 KB | Output is correct |
13 | Correct | 319 ms | 3192 KB | Output is correct |
14 | Correct | 313 ms | 3352 KB | Output is correct |
15 | Correct | 622 ms | 4376 KB | Output is correct |
16 | Correct | 392 ms | 3704 KB | Output is correct |
17 | Correct | 395 ms | 3576 KB | Output is correct |
18 | Correct | 245 ms | 5624 KB | Output is correct |
19 | Correct | 237 ms | 7416 KB | Output is correct |
20 | Correct | 609 ms | 9204 KB | Output is correct |
21 | Correct | 1016 ms | 9048 KB | Output is correct |
22 | Correct | 1038 ms | 9528 KB | Output is correct |
23 | Correct | 440 ms | 8268 KB | Output is correct |
24 | Correct | 422 ms | 8184 KB | Output is correct |
25 | Correct | 1624 ms | 10260 KB | Output is correct |
26 | Correct | 565 ms | 8672 KB | Output is correct |
27 | Correct | 574 ms | 8668 KB | Output is correct |
28 | Correct | 275 ms | 11128 KB | Output is correct |
29 | Correct | 267 ms | 7156 KB | Output is correct |
30 | Correct | 1069 ms | 9176 KB | Output is correct |
31 | Correct | 708 ms | 9164 KB | Output is correct |
32 | Correct | 534 ms | 9224 KB | Output is correct |
33 | Correct | 370 ms | 7928 KB | Output is correct |
34 | Correct | 423 ms | 8184 KB | Output is correct |
35 | Correct | 571 ms | 8488 KB | Output is correct |
36 | Correct | 258 ms | 7096 KB | Output is correct |
37 | Correct | 701 ms | 9068 KB | Output is correct |
38 | Correct | 277 ms | 7120 KB | Output is correct |
39 | Correct | 443 ms | 8368 KB | Output is correct |
40 | Correct | 422 ms | 8028 KB | Output is correct |
41 | Correct | 369 ms | 9904 KB | Output is correct |
42 | Correct | 94 ms | 9848 KB | Output is correct |
43 | Correct | 79 ms | 11768 KB | Output is correct |
44 | Correct | 101 ms | 11848 KB | Output is correct |
45 | Correct | 64 ms | 11896 KB | Output is correct |
46 | Correct | 107 ms | 11768 KB | Output is correct |
47 | Correct | 108 ms | 11768 KB | Output is correct |
48 | Correct | 57 ms | 12024 KB | Output is correct |
49 | Correct | 57 ms | 11640 KB | Output is correct |
50 | Correct | 197 ms | 11960 KB | Output is correct |
51 | Correct | 80 ms | 11884 KB | Output is correct |
52 | Correct | 99 ms | 11836 KB | Output is correct |
53 | Correct | 64 ms | 11768 KB | Output is correct |
54 | Correct | 83 ms | 11772 KB | Output is correct |
55 | Correct | 105 ms | 11896 KB | Output is correct |
56 | Correct | 54 ms | 11768 KB | Output is correct |
57 | Correct | 56 ms | 11896 KB | Output is correct |
58 | Correct | 58 ms | 11640 KB | Output is correct |
59 | Correct | 79 ms | 11768 KB | Output is correct |
60 | Correct | 81 ms | 11772 KB | Output is correct |
61 | Correct | 64 ms | 11800 KB | Output is correct |
62 | Correct | 114 ms | 11844 KB | Output is correct |
63 | Correct | 103 ms | 11824 KB | Output is correct |
64 | Correct | 54 ms | 11668 KB | Output is correct |
65 | Correct | 108 ms | 11768 KB | Output is correct |
66 | Correct | 108 ms | 11868 KB | Output is correct |
67 | Correct | 106 ms | 11896 KB | Output is correct |
68 | Correct | 116 ms | 11868 KB | Output is correct |
69 | Correct | 113 ms | 11896 KB | Output is correct |
70 | Correct | 112 ms | 11804 KB | Output is correct |
71 | Execution timed out | 2065 ms | 14816 KB | Time limit exceeded |
72 | Halted | 0 ms | 0 KB | - |