답안 #289820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289820 2020-09-03T06:08:22 Z Pyqe Snake Escaping (JOI18_snake_escaping) C++14
5 / 100
2000 ms 65540 KB
#include <bits/stdc++.h>

using namespace std;

int nd,n,d,d2,p3[11],dh[59049],pst[59049],a[1ll<<20],dp[1ll<<10][59049];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t,rr,i,k,w,ww,mk,mkk,z;
	string s;
	
	p3[0]=1;
	for(i=1;i<=10;i++)
	{
		p3[i]=p3[i-1]*3;
	}
	for(mk=0;mk<p3[10];mk++)
	{
		w=0;
		for(i=9;i+1;i--)
		{
			k=mk/p3[i]%3;
			if(k==2)
			{
				break;
			}
			w=w<<1|k;
		}
		dh[mk]=i;
		if(dh[mk]==-1)
		{
			pst[mk]=w;
		}
	}
	cin>>nd>>t;
	n=1ll<<nd;
	d=min(nd,10);
	d2=max(nd-10,0);
	cin>>s;
	for(i=0;i<n;i++)
	{
		a[i]=s[i]-'0';
	}
	for(i=0;i<1ll<<d;i++)
	{
		for(mk=0;mk<p3[d2];mk++)
		{
			if(dh[mk]==-1)
			{
				dp[i][mk]=a[i<<d2|pst[mk]];
			}
			else
			{
				dp[i][mk]=dp[i][mk-p3[dh[mk]]*2]+dp[i][mk-p3[dh[mk]]];
			}
		}
	}
	for(rr=0;rr<t;rr++)
	{
		cin>>s;
		w=0;
		ww=0;
		for(i=0;i<d;i++)
		{
			k=(s[i]=='1')+2*(s[i]=='?');
			w=w<<1|k%2;
			ww=ww<<1|k/2;
		}
		mk=0;
		for(i=0;i<d2;i++)
		{
			k=(s[d+i]=='1')+2*(s[d+i]=='?');
			mk=mk*3+k;
		}
		z=0;
		for(mkk=ww;1;mkk=mkk-1&ww)
		{
			z+=dp[mkk|w][mk];
			if(!mkk)
			{
				break;
			}
		}
		cout<<z<<"\n";
	}
}

Compilation message

snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:79:23: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   79 |   for(mkk=ww;1;mkk=mkk-1&ww)
      |                    ~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5248 KB Output is correct
2 Correct 4 ms 5248 KB Output is correct
3 Correct 4 ms 5248 KB Output is correct
4 Correct 4 ms 5248 KB Output is correct
5 Correct 4 ms 5120 KB Output is correct
6 Correct 4 ms 5248 KB Output is correct
7 Correct 4 ms 5248 KB Output is correct
8 Correct 6 ms 5248 KB Output is correct
9 Correct 4 ms 5248 KB Output is correct
10 Correct 4 ms 5248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5248 KB Output is correct
2 Correct 4 ms 5248 KB Output is correct
3 Correct 4 ms 5248 KB Output is correct
4 Correct 4 ms 5248 KB Output is correct
5 Correct 4 ms 5120 KB Output is correct
6 Correct 4 ms 5248 KB Output is correct
7 Correct 4 ms 5248 KB Output is correct
8 Correct 6 ms 5248 KB Output is correct
9 Correct 4 ms 5248 KB Output is correct
10 Correct 4 ms 5248 KB Output is correct
11 Correct 245 ms 12792 KB Output is correct
12 Correct 324 ms 19576 KB Output is correct
13 Correct 212 ms 18936 KB Output is correct
14 Correct 211 ms 18936 KB Output is correct
15 Correct 382 ms 20092 KB Output is correct
16 Correct 247 ms 19192 KB Output is correct
17 Correct 254 ms 19064 KB Output is correct
18 Execution timed out 2008 ms 21240 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5248 KB Output is correct
2 Correct 4 ms 5248 KB Output is correct
3 Correct 4 ms 5248 KB Output is correct
4 Correct 4 ms 5248 KB Output is correct
5 Correct 4 ms 5120 KB Output is correct
6 Correct 4 ms 5248 KB Output is correct
7 Correct 4 ms 5248 KB Output is correct
8 Correct 6 ms 5248 KB Output is correct
9 Correct 4 ms 5248 KB Output is correct
10 Correct 4 ms 5248 KB Output is correct
11 Correct 245 ms 12792 KB Output is correct
12 Correct 324 ms 19576 KB Output is correct
13 Correct 212 ms 18936 KB Output is correct
14 Correct 211 ms 18936 KB Output is correct
15 Correct 382 ms 20092 KB Output is correct
16 Correct 247 ms 19192 KB Output is correct
17 Correct 254 ms 19064 KB Output is correct
18 Execution timed out 2008 ms 21240 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5248 KB Output is correct
2 Correct 4 ms 5248 KB Output is correct
3 Correct 4 ms 5248 KB Output is correct
4 Correct 4 ms 5248 KB Output is correct
5 Correct 4 ms 5120 KB Output is correct
6 Correct 4 ms 5248 KB Output is correct
7 Correct 4 ms 5248 KB Output is correct
8 Correct 6 ms 5248 KB Output is correct
9 Correct 4 ms 5248 KB Output is correct
10 Correct 4 ms 5248 KB Output is correct
11 Runtime error 85 ms 65540 KB Execution killed with signal 9
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5248 KB Output is correct
2 Correct 4 ms 5248 KB Output is correct
3 Correct 4 ms 5248 KB Output is correct
4 Correct 4 ms 5248 KB Output is correct
5 Correct 4 ms 5120 KB Output is correct
6 Correct 4 ms 5248 KB Output is correct
7 Correct 4 ms 5248 KB Output is correct
8 Correct 6 ms 5248 KB Output is correct
9 Correct 4 ms 5248 KB Output is correct
10 Correct 4 ms 5248 KB Output is correct
11 Correct 245 ms 12792 KB Output is correct
12 Correct 324 ms 19576 KB Output is correct
13 Correct 212 ms 18936 KB Output is correct
14 Correct 211 ms 18936 KB Output is correct
15 Correct 382 ms 20092 KB Output is correct
16 Correct 247 ms 19192 KB Output is correct
17 Correct 254 ms 19064 KB Output is correct
18 Execution timed out 2008 ms 21240 KB Time limit exceeded
19 Halted 0 ms 0 KB -