# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
80208 | 2018-10-19T14:33:01 Z | Bodo171 | Snake Escaping (JOI18_snake_escaping) | C++14 | 444 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],v[nmax]; int sub[nmax],supra[nmax]; int l,q,i,j,m0,m1,mq,mn,ans; 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]=v[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=min(min(pc[m0],pc[m1]),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+=v[(m1|i)]; if(i==0) brk=1; i=((i-1)&mq); } } } cout<<ans<<'\n'; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 3 ms | 588 KB | Output is correct |
5 | Correct | 2 ms | 588 KB | Output is correct |
6 | Correct | 2 ms | 588 KB | Output is correct |
7 | Correct | 2 ms | 588 KB | Output is correct |
8 | Correct | 2 ms | 688 KB | Output is correct |
9 | Correct | 2 ms | 688 KB | Output is correct |
10 | Correct | 3 ms | 688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 3 ms | 588 KB | Output is correct |
5 | Correct | 2 ms | 588 KB | Output is correct |
6 | Correct | 2 ms | 588 KB | Output is correct |
7 | Correct | 2 ms | 588 KB | Output is correct |
8 | Correct | 2 ms | 688 KB | Output is correct |
9 | Correct | 2 ms | 688 KB | Output is correct |
10 | Correct | 3 ms | 688 KB | Output is correct |
11 | Correct | 339 ms | 4424 KB | Output is correct |
12 | Correct | 285 ms | 4424 KB | Output is correct |
13 | Correct | 312 ms | 4424 KB | Output is correct |
14 | Correct | 370 ms | 4424 KB | Output is correct |
15 | Correct | 305 ms | 4524 KB | Output is correct |
16 | Correct | 337 ms | 4524 KB | Output is correct |
17 | Correct | 322 ms | 4524 KB | Output is correct |
18 | Correct | 239 ms | 5560 KB | Output is correct |
19 | Correct | 274 ms | 5560 KB | Output is correct |
20 | Correct | 297 ms | 5560 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 3 ms | 588 KB | Output is correct |
5 | Correct | 2 ms | 588 KB | Output is correct |
6 | Correct | 2 ms | 588 KB | Output is correct |
7 | Correct | 2 ms | 588 KB | Output is correct |
8 | Correct | 2 ms | 688 KB | Output is correct |
9 | Correct | 2 ms | 688 KB | Output is correct |
10 | Correct | 3 ms | 688 KB | Output is correct |
11 | Correct | 339 ms | 4424 KB | Output is correct |
12 | Correct | 285 ms | 4424 KB | Output is correct |
13 | Correct | 312 ms | 4424 KB | Output is correct |
14 | Correct | 370 ms | 4424 KB | Output is correct |
15 | Correct | 305 ms | 4524 KB | Output is correct |
16 | Correct | 337 ms | 4524 KB | Output is correct |
17 | Correct | 322 ms | 4524 KB | Output is correct |
18 | Correct | 239 ms | 5560 KB | Output is correct |
19 | Correct | 274 ms | 5560 KB | Output is correct |
20 | Correct | 297 ms | 5560 KB | Output is correct |
21 | Correct | 355 ms | 5560 KB | Output is correct |
22 | Correct | 353 ms | 5560 KB | Output is correct |
23 | Correct | 377 ms | 5560 KB | Output is correct |
24 | Correct | 442 ms | 5560 KB | Output is correct |
25 | Correct | 344 ms | 5560 KB | Output is correct |
26 | Correct | 394 ms | 5560 KB | Output is correct |
27 | Correct | 393 ms | 5560 KB | Output is correct |
28 | Correct | 266 ms | 20240 KB | Output is correct |
29 | Correct | 315 ms | 20240 KB | Output is correct |
30 | Correct | 332 ms | 20240 KB | Output is correct |
31 | Correct | 371 ms | 20240 KB | Output is correct |
32 | Correct | 407 ms | 20240 KB | Output is correct |
33 | Correct | 335 ms | 31596 KB | Output is correct |
34 | Correct | 407 ms | 39144 KB | Output is correct |
35 | Correct | 444 ms | 39144 KB | Output is correct |
36 | Correct | 254 ms | 39664 KB | Output is correct |
37 | Correct | 342 ms | 46388 KB | Output is correct |
38 | Correct | 362 ms | 48612 KB | Output is correct |
39 | Correct | 403 ms | 59388 KB | Output is correct |
40 | Runtime error | 402 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. |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 3 ms | 588 KB | Output is correct |
5 | Correct | 2 ms | 588 KB | Output is correct |
6 | Correct | 2 ms | 588 KB | Output is correct |
7 | Correct | 2 ms | 588 KB | Output is correct |
8 | Correct | 2 ms | 688 KB | Output is correct |
9 | Correct | 2 ms | 688 KB | Output is correct |
10 | Correct | 3 ms | 688 KB | Output is correct |
11 | Runtime error | 87 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. |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 588 KB | Output is correct |
4 | Correct | 3 ms | 588 KB | Output is correct |
5 | Correct | 2 ms | 588 KB | Output is correct |
6 | Correct | 2 ms | 588 KB | Output is correct |
7 | Correct | 2 ms | 588 KB | Output is correct |
8 | Correct | 2 ms | 688 KB | Output is correct |
9 | Correct | 2 ms | 688 KB | Output is correct |
10 | Correct | 3 ms | 688 KB | Output is correct |
11 | Correct | 339 ms | 4424 KB | Output is correct |
12 | Correct | 285 ms | 4424 KB | Output is correct |
13 | Correct | 312 ms | 4424 KB | Output is correct |
14 | Correct | 370 ms | 4424 KB | Output is correct |
15 | Correct | 305 ms | 4524 KB | Output is correct |
16 | Correct | 337 ms | 4524 KB | Output is correct |
17 | Correct | 322 ms | 4524 KB | Output is correct |
18 | Correct | 239 ms | 5560 KB | Output is correct |
19 | Correct | 274 ms | 5560 KB | Output is correct |
20 | Correct | 297 ms | 5560 KB | Output is correct |
21 | Correct | 355 ms | 5560 KB | Output is correct |
22 | Correct | 353 ms | 5560 KB | Output is correct |
23 | Correct | 377 ms | 5560 KB | Output is correct |
24 | Correct | 442 ms | 5560 KB | Output is correct |
25 | Correct | 344 ms | 5560 KB | Output is correct |
26 | Correct | 394 ms | 5560 KB | Output is correct |
27 | Correct | 393 ms | 5560 KB | Output is correct |
28 | Correct | 266 ms | 20240 KB | Output is correct |
29 | Correct | 315 ms | 20240 KB | Output is correct |
30 | Correct | 332 ms | 20240 KB | Output is correct |
31 | Correct | 371 ms | 20240 KB | Output is correct |
32 | Correct | 407 ms | 20240 KB | Output is correct |
33 | Correct | 335 ms | 31596 KB | Output is correct |
34 | Correct | 407 ms | 39144 KB | Output is correct |
35 | Correct | 444 ms | 39144 KB | Output is correct |
36 | Correct | 254 ms | 39664 KB | Output is correct |
37 | Correct | 342 ms | 46388 KB | Output is correct |
38 | Correct | 362 ms | 48612 KB | Output is correct |
39 | Correct | 403 ms | 59388 KB | Output is correct |
40 | Runtime error | 402 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. |