# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
80240 | 2018-10-19T16:23:15 Z | Bodo171 | Snake Escaping (JOI18_snake_escaping) | C++14 | 903 ms | 66560 KB |
#include <cstdio> //#include <iostream> using namespace std; const int nmax=(1<<20)+5; char s[22],str[nmax]; char t; char pc[nmax]; int sub[nmax],supra[nmax]; int l,q,i,j,m0,m1,mq,ans; char mn; bool brk; int main() { //freopen("data.in","r",stdin); scanf("%d%d",&l,&q); scanf("%s",&str); for(i=0;i<(1<<l);i++) { if(i!=0) pc[i]=pc[(i&(i-1))]+1; sub[i]=supra[i]=str[i]=str[i]-'0'; } for(i=0;i<l;i++) for(j=0;j<(1<<l);j++) if(((1<<i)&j)) sub[j]+=sub[(j^(1<<i))]; else supra[j]+=supra[(j^(1<<i))]; for(int cnt=1;cnt<=q;cnt++) { scanf("%s",&s); m0=m1=mq=0; for(j=l-1;j>=0;j--) { t=s[l-1-j]; if(t=='0') m0+=(1<<j); else if(t=='1') m1+=(1<<j); else mq+=(1<<j); } mn=pc[m0]; if(pc[m1]<mn) mn=pc[m1]; if(pc[mq]<mn) mn=pc[mq]; ans=0;brk=0; if(mn==pc[m0]) { ans=supra[m1]; i=m0; while(i!=0) { if((pc[i]&1)) ans-=supra[(i|m1)]; else ans+=supra[(i|m1)]; i=((i-1)&m0); } } else { if(mn==pc[m1]) { i=m1; while(!brk) { if(i==0) brk=1; if(((pc[m1]-pc[i])&1)) ans-=sub[(i|mq)]; else ans+=sub[(i|mq)]; i=((i-1)&m1); } } else { i=mq; while(!brk) { ans+=str[(m1|i)]; if(i==0) brk=1; i=((i-1)&mq); } } } printf("%d\n",ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 460 KB | Output is correct |
3 | Correct | 2 ms | 464 KB | Output is correct |
4 | Correct | 3 ms | 476 KB | Output is correct |
5 | Correct | 3 ms | 536 KB | Output is correct |
6 | Correct | 3 ms | 564 KB | Output is correct |
7 | Correct | 2 ms | 576 KB | Output is correct |
8 | Correct | 2 ms | 600 KB | Output is correct |
9 | Correct | 2 ms | 740 KB | Output is correct |
10 | Correct | 2 ms | 780 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 460 KB | Output is correct |
3 | Correct | 2 ms | 464 KB | Output is correct |
4 | Correct | 3 ms | 476 KB | Output is correct |
5 | Correct | 3 ms | 536 KB | Output is correct |
6 | Correct | 3 ms | 564 KB | Output is correct |
7 | Correct | 2 ms | 576 KB | Output is correct |
8 | Correct | 2 ms | 600 KB | Output is correct |
9 | Correct | 2 ms | 740 KB | Output is correct |
10 | Correct | 2 ms | 780 KB | Output is correct |
11 | Correct | 284 ms | 4892 KB | Output is correct |
12 | Correct | 305 ms | 4892 KB | Output is correct |
13 | Correct | 323 ms | 4892 KB | Output is correct |
14 | Correct | 339 ms | 4892 KB | Output is correct |
15 | Correct | 332 ms | 4944 KB | Output is correct |
16 | Correct | 355 ms | 4944 KB | Output is correct |
17 | Correct | 363 ms | 4944 KB | Output is correct |
18 | Correct | 240 ms | 6036 KB | Output is correct |
19 | Correct | 292 ms | 6036 KB | Output is correct |
20 | Correct | 299 ms | 6036 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 460 KB | Output is correct |
3 | Correct | 2 ms | 464 KB | Output is correct |
4 | Correct | 3 ms | 476 KB | Output is correct |
5 | Correct | 3 ms | 536 KB | Output is correct |
6 | Correct | 3 ms | 564 KB | Output is correct |
7 | Correct | 2 ms | 576 KB | Output is correct |
8 | Correct | 2 ms | 600 KB | Output is correct |
9 | Correct | 2 ms | 740 KB | Output is correct |
10 | Correct | 2 ms | 780 KB | Output is correct |
11 | Correct | 284 ms | 4892 KB | Output is correct |
12 | Correct | 305 ms | 4892 KB | Output is correct |
13 | Correct | 323 ms | 4892 KB | Output is correct |
14 | Correct | 339 ms | 4892 KB | Output is correct |
15 | Correct | 332 ms | 4944 KB | Output is correct |
16 | Correct | 355 ms | 4944 KB | Output is correct |
17 | Correct | 363 ms | 4944 KB | Output is correct |
18 | Correct | 240 ms | 6036 KB | Output is correct |
19 | Correct | 292 ms | 6036 KB | Output is correct |
20 | Correct | 299 ms | 6036 KB | Output is correct |
21 | Correct | 328 ms | 6036 KB | Output is correct |
22 | Correct | 347 ms | 6036 KB | Output is correct |
23 | Correct | 410 ms | 6036 KB | Output is correct |
24 | Correct | 416 ms | 6036 KB | Output is correct |
25 | Correct | 394 ms | 6108 KB | Output is correct |
26 | Correct | 426 ms | 6108 KB | Output is correct |
27 | Correct | 415 ms | 6108 KB | Output is correct |
28 | Correct | 271 ms | 7084 KB | Output is correct |
29 | Correct | 352 ms | 7084 KB | Output is correct |
30 | Correct | 356 ms | 7084 KB | Output is correct |
31 | Correct | 466 ms | 7084 KB | Output is correct |
32 | Correct | 445 ms | 7084 KB | Output is correct |
33 | Correct | 356 ms | 7084 KB | Output is correct |
34 | Correct | 401 ms | 7084 KB | Output is correct |
35 | Correct | 401 ms | 7084 KB | Output is correct |
36 | Correct | 286 ms | 7084 KB | Output is correct |
37 | Correct | 344 ms | 7084 KB | Output is correct |
38 | Correct | 325 ms | 7084 KB | Output is correct |
39 | Correct | 379 ms | 7084 KB | Output is correct |
40 | Correct | 386 ms | 7084 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 460 KB | Output is correct |
3 | Correct | 2 ms | 464 KB | Output is correct |
4 | Correct | 3 ms | 476 KB | Output is correct |
5 | Correct | 3 ms | 536 KB | Output is correct |
6 | Correct | 3 ms | 564 KB | Output is correct |
7 | Correct | 2 ms | 576 KB | Output is correct |
8 | Correct | 2 ms | 600 KB | Output is correct |
9 | Correct | 2 ms | 740 KB | Output is correct |
10 | Correct | 2 ms | 780 KB | Output is correct |
11 | Correct | 67 ms | 11436 KB | Output is correct |
12 | Correct | 76 ms | 11488 KB | Output is correct |
13 | Correct | 95 ms | 11488 KB | Output is correct |
14 | Correct | 84 ms | 11564 KB | Output is correct |
15 | Correct | 66 ms | 11564 KB | Output is correct |
16 | Correct | 80 ms | 11564 KB | Output is correct |
17 | Correct | 89 ms | 11564 KB | Output is correct |
18 | Correct | 61 ms | 11692 KB | Output is correct |
19 | Correct | 93 ms | 11692 KB | Output is correct |
20 | Correct | 67 ms | 11692 KB | Output is correct |
21 | Correct | 70 ms | 11692 KB | Output is correct |
22 | Correct | 78 ms | 11692 KB | Output is correct |
23 | Correct | 65 ms | 11692 KB | Output is correct |
24 | Correct | 80 ms | 11692 KB | Output is correct |
25 | Correct | 77 ms | 11692 KB | Output is correct |
26 | Correct | 57 ms | 11692 KB | Output is correct |
27 | Correct | 65 ms | 11692 KB | Output is correct |
28 | Correct | 66 ms | 11692 KB | Output is correct |
29 | Correct | 70 ms | 11692 KB | Output is correct |
30 | Correct | 84 ms | 11692 KB | Output is correct |
31 | Correct | 74 ms | 11692 KB | Output is correct |
32 | Correct | 83 ms | 11692 KB | Output is correct |
33 | Correct | 84 ms | 11692 KB | Output is correct |
34 | Correct | 59 ms | 11692 KB | Output is correct |
35 | Correct | 72 ms | 11692 KB | Output is correct |
36 | Correct | 76 ms | 11692 KB | Output is correct |
37 | Correct | 75 ms | 11692 KB | Output is correct |
38 | Correct | 76 ms | 11692 KB | Output is correct |
39 | Correct | 71 ms | 11692 KB | Output is correct |
40 | Correct | 72 ms | 11692 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 460 KB | Output is correct |
3 | Correct | 2 ms | 464 KB | Output is correct |
4 | Correct | 3 ms | 476 KB | Output is correct |
5 | Correct | 3 ms | 536 KB | Output is correct |
6 | Correct | 3 ms | 564 KB | Output is correct |
7 | Correct | 2 ms | 576 KB | Output is correct |
8 | Correct | 2 ms | 600 KB | Output is correct |
9 | Correct | 2 ms | 740 KB | Output is correct |
10 | Correct | 2 ms | 780 KB | Output is correct |
11 | Correct | 284 ms | 4892 KB | Output is correct |
12 | Correct | 305 ms | 4892 KB | Output is correct |
13 | Correct | 323 ms | 4892 KB | Output is correct |
14 | Correct | 339 ms | 4892 KB | Output is correct |
15 | Correct | 332 ms | 4944 KB | Output is correct |
16 | Correct | 355 ms | 4944 KB | Output is correct |
17 | Correct | 363 ms | 4944 KB | Output is correct |
18 | Correct | 240 ms | 6036 KB | Output is correct |
19 | Correct | 292 ms | 6036 KB | Output is correct |
20 | Correct | 299 ms | 6036 KB | Output is correct |
21 | Correct | 328 ms | 6036 KB | Output is correct |
22 | Correct | 347 ms | 6036 KB | Output is correct |
23 | Correct | 410 ms | 6036 KB | Output is correct |
24 | Correct | 416 ms | 6036 KB | Output is correct |
25 | Correct | 394 ms | 6108 KB | Output is correct |
26 | Correct | 426 ms | 6108 KB | Output is correct |
27 | Correct | 415 ms | 6108 KB | Output is correct |
28 | Correct | 271 ms | 7084 KB | Output is correct |
29 | Correct | 352 ms | 7084 KB | Output is correct |
30 | Correct | 356 ms | 7084 KB | Output is correct |
31 | Correct | 466 ms | 7084 KB | Output is correct |
32 | Correct | 445 ms | 7084 KB | Output is correct |
33 | Correct | 356 ms | 7084 KB | Output is correct |
34 | Correct | 401 ms | 7084 KB | Output is correct |
35 | Correct | 401 ms | 7084 KB | Output is correct |
36 | Correct | 286 ms | 7084 KB | Output is correct |
37 | Correct | 344 ms | 7084 KB | Output is correct |
38 | Correct | 325 ms | 7084 KB | Output is correct |
39 | Correct | 379 ms | 7084 KB | Output is correct |
40 | Correct | 386 ms | 7084 KB | Output is correct |
41 | Correct | 67 ms | 11436 KB | Output is correct |
42 | Correct | 76 ms | 11488 KB | Output is correct |
43 | Correct | 95 ms | 11488 KB | Output is correct |
44 | Correct | 84 ms | 11564 KB | Output is correct |
45 | Correct | 66 ms | 11564 KB | Output is correct |
46 | Correct | 80 ms | 11564 KB | Output is correct |
47 | Correct | 89 ms | 11564 KB | Output is correct |
48 | Correct | 61 ms | 11692 KB | Output is correct |
49 | Correct | 93 ms | 11692 KB | Output is correct |
50 | Correct | 67 ms | 11692 KB | Output is correct |
51 | Correct | 70 ms | 11692 KB | Output is correct |
52 | Correct | 78 ms | 11692 KB | Output is correct |
53 | Correct | 65 ms | 11692 KB | Output is correct |
54 | Correct | 80 ms | 11692 KB | Output is correct |
55 | Correct | 77 ms | 11692 KB | Output is correct |
56 | Correct | 57 ms | 11692 KB | Output is correct |
57 | Correct | 65 ms | 11692 KB | Output is correct |
58 | Correct | 66 ms | 11692 KB | Output is correct |
59 | Correct | 70 ms | 11692 KB | Output is correct |
60 | Correct | 84 ms | 11692 KB | Output is correct |
61 | Correct | 74 ms | 11692 KB | Output is correct |
62 | Correct | 83 ms | 11692 KB | Output is correct |
63 | Correct | 84 ms | 11692 KB | Output is correct |
64 | Correct | 59 ms | 11692 KB | Output is correct |
65 | Correct | 72 ms | 11692 KB | Output is correct |
66 | Correct | 76 ms | 11692 KB | Output is correct |
67 | Correct | 75 ms | 11692 KB | Output is correct |
68 | Correct | 76 ms | 11692 KB | Output is correct |
69 | Correct | 71 ms | 11692 KB | Output is correct |
70 | Correct | 72 ms | 11692 KB | Output is correct |
71 | Correct | 475 ms | 16188 KB | Output is correct |
72 | Correct | 517 ms | 16340 KB | Output is correct |
73 | Correct | 591 ms | 16340 KB | Output is correct |
74 | Correct | 833 ms | 36936 KB | Output is correct |
75 | Correct | 521 ms | 42464 KB | Output is correct |
76 | Correct | 903 ms | 42464 KB | Output is correct |
77 | Correct | 868 ms | 42464 KB | Output is correct |
78 | Runtime error | 344 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. |
79 | Halted | 0 ms | 0 KB | - |