# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
256743 | 2020-08-03T07:36:40 Z | 반딧불(#5039) | Snake Escaping (JOI18_snake_escaping) | C++17 | 2000 ms | 19168 KB |
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; typedef long long ll; int n, q; int arr[1048576]; int DP[1048576]; /// 0�� Ȯ��, 1�� 0and1 int DP2[1048576]; /// 1�� Ȯ��, 0�� 0and1 int main(){ scanf("%d %d", &n, &q); for(int i=0; i<(1<<n); i++){ scanf("%1d", &arr[i]); DP[i] = DP2[i] = arr[i]; } for(int d=0; d<n; d++){ for(int i=0; i<(1<<n); i++){ if(i & (1<<d)) DP[i] += DP[i-(1<<d)]; else DP2[i] += DP2[i+(1<<d)]; } } for(int i=1; i<=q; i++){ int one = 0; int zero = 0; int lft = 0; for(int j=n-1; j>=0; j--){ char c; scanf(" %c", &c); if(c=='1') one |= (1<<j); else if(c=='0') zero |= (1<<j); else lft |= (1<<j); } int ans = 0; if(__builtin_popcount(one) > __builtin_popcount(zero)){ for(int x=zero; 1; x = (x-1)&zero){ ans += DP2[one|x] * (__builtin_popcount(x) & 1 ? -1 : 1); if(!x) break; } } else{ for(int x=one; 1; x = (x-1)&one){ ans += DP[lft|x] * (__builtin_popcount(one ^ x) & 1 ? -1 : 1); if(!x) break; } } printf("%d\n", ans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 778 ms | 6136 KB | Output is correct |
12 | Correct | 796 ms | 5712 KB | Output is correct |
13 | Correct | 801 ms | 5112 KB | Output is correct |
14 | Correct | 801 ms | 5080 KB | Output is correct |
15 | Correct | 764 ms | 6008 KB | Output is correct |
16 | Correct | 795 ms | 5240 KB | Output is correct |
17 | Correct | 811 ms | 5240 KB | Output is correct |
18 | Correct | 759 ms | 7224 KB | Output is correct |
19 | Correct | 825 ms | 3960 KB | Output is correct |
20 | Correct | 764 ms | 5764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 778 ms | 6136 KB | Output is correct |
12 | Correct | 796 ms | 5712 KB | Output is correct |
13 | Correct | 801 ms | 5112 KB | Output is correct |
14 | Correct | 801 ms | 5080 KB | Output is correct |
15 | Correct | 764 ms | 6008 KB | Output is correct |
16 | Correct | 795 ms | 5240 KB | Output is correct |
17 | Correct | 811 ms | 5240 KB | Output is correct |
18 | Correct | 759 ms | 7224 KB | Output is correct |
19 | Correct | 825 ms | 3960 KB | Output is correct |
20 | Correct | 764 ms | 5764 KB | Output is correct |
21 | Correct | 952 ms | 6180 KB | Output is correct |
22 | Correct | 976 ms | 6392 KB | Output is correct |
23 | Correct | 1032 ms | 5316 KB | Output is correct |
24 | Correct | 1022 ms | 5352 KB | Output is correct |
25 | Correct | 1002 ms | 7160 KB | Output is correct |
26 | Correct | 1016 ms | 5496 KB | Output is correct |
27 | Correct | 1037 ms | 5688 KB | Output is correct |
28 | Correct | 944 ms | 8304 KB | Output is correct |
29 | Correct | 1080 ms | 4376 KB | Output is correct |
30 | Correct | 977 ms | 6464 KB | Output is correct |
31 | Correct | 1030 ms | 6268 KB | Output is correct |
32 | Correct | 1026 ms | 6344 KB | Output is correct |
33 | Correct | 1051 ms | 5156 KB | Output is correct |
34 | Correct | 1093 ms | 5584 KB | Output is correct |
35 | Correct | 1093 ms | 6032 KB | Output is correct |
36 | Correct | 1085 ms | 4468 KB | Output is correct |
37 | Correct | 983 ms | 6568 KB | Output is correct |
38 | Correct | 1069 ms | 4472 KB | Output is correct |
39 | Correct | 1047 ms | 5728 KB | Output is correct |
40 | Correct | 1041 ms | 5624 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 206 ms | 14456 KB | Output is correct |
12 | Correct | 214 ms | 14584 KB | Output is correct |
13 | Correct | 206 ms | 14456 KB | Output is correct |
14 | Correct | 223 ms | 14444 KB | Output is correct |
15 | Correct | 209 ms | 14584 KB | Output is correct |
16 | Correct | 240 ms | 14480 KB | Output is correct |
17 | Correct | 228 ms | 14544 KB | Output is correct |
18 | Correct | 205 ms | 14648 KB | Output is correct |
19 | Correct | 317 ms | 14464 KB | Output is correct |
20 | Correct | 200 ms | 14584 KB | Output is correct |
21 | Correct | 215 ms | 14528 KB | Output is correct |
22 | Correct | 222 ms | 14540 KB | Output is correct |
23 | Correct | 227 ms | 14392 KB | Output is correct |
24 | Correct | 238 ms | 14472 KB | Output is correct |
25 | Correct | 228 ms | 14456 KB | Output is correct |
26 | Correct | 217 ms | 14328 KB | Output is correct |
27 | Correct | 227 ms | 14528 KB | Output is correct |
28 | Correct | 269 ms | 14456 KB | Output is correct |
29 | Correct | 219 ms | 14584 KB | Output is correct |
30 | Correct | 227 ms | 14584 KB | Output is correct |
31 | Correct | 215 ms | 14456 KB | Output is correct |
32 | Correct | 244 ms | 14524 KB | Output is correct |
33 | Correct | 241 ms | 14460 KB | Output is correct |
34 | Correct | 194 ms | 14584 KB | Output is correct |
35 | Correct | 246 ms | 14456 KB | Output is correct |
36 | Correct | 219 ms | 14584 KB | Output is correct |
37 | Correct | 215 ms | 14584 KB | Output is correct |
38 | Correct | 235 ms | 14456 KB | Output is correct |
39 | Correct | 227 ms | 14456 KB | Output is correct |
40 | Correct | 219 ms | 14456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 778 ms | 6136 KB | Output is correct |
12 | Correct | 796 ms | 5712 KB | Output is correct |
13 | Correct | 801 ms | 5112 KB | Output is correct |
14 | Correct | 801 ms | 5080 KB | Output is correct |
15 | Correct | 764 ms | 6008 KB | Output is correct |
16 | Correct | 795 ms | 5240 KB | Output is correct |
17 | Correct | 811 ms | 5240 KB | Output is correct |
18 | Correct | 759 ms | 7224 KB | Output is correct |
19 | Correct | 825 ms | 3960 KB | Output is correct |
20 | Correct | 764 ms | 5764 KB | Output is correct |
21 | Correct | 952 ms | 6180 KB | Output is correct |
22 | Correct | 976 ms | 6392 KB | Output is correct |
23 | Correct | 1032 ms | 5316 KB | Output is correct |
24 | Correct | 1022 ms | 5352 KB | Output is correct |
25 | Correct | 1002 ms | 7160 KB | Output is correct |
26 | Correct | 1016 ms | 5496 KB | Output is correct |
27 | Correct | 1037 ms | 5688 KB | Output is correct |
28 | Correct | 944 ms | 8304 KB | Output is correct |
29 | Correct | 1080 ms | 4376 KB | Output is correct |
30 | Correct | 977 ms | 6464 KB | Output is correct |
31 | Correct | 1030 ms | 6268 KB | Output is correct |
32 | Correct | 1026 ms | 6344 KB | Output is correct |
33 | Correct | 1051 ms | 5156 KB | Output is correct |
34 | Correct | 1093 ms | 5584 KB | Output is correct |
35 | Correct | 1093 ms | 6032 KB | Output is correct |
36 | Correct | 1085 ms | 4468 KB | Output is correct |
37 | Correct | 983 ms | 6568 KB | Output is correct |
38 | Correct | 1069 ms | 4472 KB | Output is correct |
39 | Correct | 1047 ms | 5728 KB | Output is correct |
40 | Correct | 1041 ms | 5624 KB | Output is correct |
41 | Correct | 206 ms | 14456 KB | Output is correct |
42 | Correct | 214 ms | 14584 KB | Output is correct |
43 | Correct | 206 ms | 14456 KB | Output is correct |
44 | Correct | 223 ms | 14444 KB | Output is correct |
45 | Correct | 209 ms | 14584 KB | Output is correct |
46 | Correct | 240 ms | 14480 KB | Output is correct |
47 | Correct | 228 ms | 14544 KB | Output is correct |
48 | Correct | 205 ms | 14648 KB | Output is correct |
49 | Correct | 317 ms | 14464 KB | Output is correct |
50 | Correct | 200 ms | 14584 KB | Output is correct |
51 | Correct | 215 ms | 14528 KB | Output is correct |
52 | Correct | 222 ms | 14540 KB | Output is correct |
53 | Correct | 227 ms | 14392 KB | Output is correct |
54 | Correct | 238 ms | 14472 KB | Output is correct |
55 | Correct | 228 ms | 14456 KB | Output is correct |
56 | Correct | 217 ms | 14328 KB | Output is correct |
57 | Correct | 227 ms | 14528 KB | Output is correct |
58 | Correct | 269 ms | 14456 KB | Output is correct |
59 | Correct | 219 ms | 14584 KB | Output is correct |
60 | Correct | 227 ms | 14584 KB | Output is correct |
61 | Correct | 215 ms | 14456 KB | Output is correct |
62 | Correct | 244 ms | 14524 KB | Output is correct |
63 | Correct | 241 ms | 14460 KB | Output is correct |
64 | Correct | 194 ms | 14584 KB | Output is correct |
65 | Correct | 246 ms | 14456 KB | Output is correct |
66 | Correct | 219 ms | 14584 KB | Output is correct |
67 | Correct | 215 ms | 14584 KB | Output is correct |
68 | Correct | 235 ms | 14456 KB | Output is correct |
69 | Correct | 227 ms | 14456 KB | Output is correct |
70 | Correct | 219 ms | 14456 KB | Output is correct |
71 | Correct | 1588 ms | 17904 KB | Output is correct |
72 | Correct | 1609 ms | 18044 KB | Output is correct |
73 | Correct | 1739 ms | 16648 KB | Output is correct |
74 | Correct | 1751 ms | 16848 KB | Output is correct |
75 | Correct | 1566 ms | 18936 KB | Output is correct |
76 | Execution timed out | 2084 ms | 19168 KB | Time limit exceeded |
77 | Halted | 0 ms | 0 KB | - |