답안 #729409

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729409 2023-04-24T03:41:40 Z pcc Snake Escaping (JOI18_snake_escaping) C++14
12 / 100
231 ms 9672 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define fs first
#define sc second

const int mxn = pow(3,11);
int ans[mxn];

void solve(){
	int n,q;
	cin>>n>>q;
	int arr[1<<n];
	for(auto &i:arr){
		char c;
		cin>>c;
		i = c-'0';
	}
	for(int i = 0;i<(1<<n);i++){
		for(int j = 0;j<(1<<n);j++){
			int total = 0;
			int p = 1;
			for(int k = 0;k<n;k++){
				if(j&(1<<k))total += p*2;
				else if(i&(1<<k))total += p;
				p *= 3;
			}
			ans[total] += arr[i];
		}
	}
	while(q--){
		string s;
		cin>>s;
		int p = 1;
		int t = 0;
		reverse(s.begin(),s.end());
		for(int i = 0;i<n;i++){
			if(s[i] == '?')t += p*2;
			else if(s[i] == '1')t += p;
			p *= 3;
		}
		cout<<ans[t]<<'\n';
	}
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	while(t--)solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 468 KB Output is correct
2 Correct 16 ms 560 KB Output is correct
3 Correct 16 ms 500 KB Output is correct
4 Correct 16 ms 504 KB Output is correct
5 Correct 16 ms 460 KB Output is correct
6 Correct 16 ms 468 KB Output is correct
7 Correct 16 ms 468 KB Output is correct
8 Correct 17 ms 468 KB Output is correct
9 Correct 17 ms 544 KB Output is correct
10 Correct 16 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 468 KB Output is correct
2 Correct 16 ms 560 KB Output is correct
3 Correct 16 ms 500 KB Output is correct
4 Correct 16 ms 504 KB Output is correct
5 Correct 16 ms 460 KB Output is correct
6 Correct 16 ms 468 KB Output is correct
7 Correct 16 ms 468 KB Output is correct
8 Correct 17 ms 468 KB Output is correct
9 Correct 17 ms 544 KB Output is correct
10 Correct 16 ms 460 KB Output is correct
11 Correct 207 ms 5848 KB Output is correct
12 Correct 215 ms 5664 KB Output is correct
13 Correct 206 ms 5044 KB Output is correct
14 Correct 204 ms 5068 KB Output is correct
15 Correct 210 ms 6004 KB Output is correct
16 Correct 231 ms 5192 KB Output is correct
17 Correct 217 ms 5260 KB Output is correct
18 Correct 167 ms 6984 KB Output is correct
19 Correct 176 ms 4060 KB Output is correct
20 Correct 228 ms 5692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 468 KB Output is correct
2 Correct 16 ms 560 KB Output is correct
3 Correct 16 ms 500 KB Output is correct
4 Correct 16 ms 504 KB Output is correct
5 Correct 16 ms 460 KB Output is correct
6 Correct 16 ms 468 KB Output is correct
7 Correct 16 ms 468 KB Output is correct
8 Correct 17 ms 468 KB Output is correct
9 Correct 17 ms 544 KB Output is correct
10 Correct 16 ms 460 KB Output is correct
11 Correct 207 ms 5848 KB Output is correct
12 Correct 215 ms 5664 KB Output is correct
13 Correct 206 ms 5044 KB Output is correct
14 Correct 204 ms 5068 KB Output is correct
15 Correct 210 ms 6004 KB Output is correct
16 Correct 231 ms 5192 KB Output is correct
17 Correct 217 ms 5260 KB Output is correct
18 Correct 167 ms 6984 KB Output is correct
19 Correct 176 ms 4060 KB Output is correct
20 Correct 228 ms 5692 KB Output is correct
21 Runtime error 2 ms 848 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 468 KB Output is correct
2 Correct 16 ms 560 KB Output is correct
3 Correct 16 ms 500 KB Output is correct
4 Correct 16 ms 504 KB Output is correct
5 Correct 16 ms 460 KB Output is correct
6 Correct 16 ms 468 KB Output is correct
7 Correct 16 ms 468 KB Output is correct
8 Correct 17 ms 468 KB Output is correct
9 Correct 17 ms 544 KB Output is correct
10 Correct 16 ms 460 KB Output is correct
11 Runtime error 19 ms 9672 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 468 KB Output is correct
2 Correct 16 ms 560 KB Output is correct
3 Correct 16 ms 500 KB Output is correct
4 Correct 16 ms 504 KB Output is correct
5 Correct 16 ms 460 KB Output is correct
6 Correct 16 ms 468 KB Output is correct
7 Correct 16 ms 468 KB Output is correct
8 Correct 17 ms 468 KB Output is correct
9 Correct 17 ms 544 KB Output is correct
10 Correct 16 ms 460 KB Output is correct
11 Correct 207 ms 5848 KB Output is correct
12 Correct 215 ms 5664 KB Output is correct
13 Correct 206 ms 5044 KB Output is correct
14 Correct 204 ms 5068 KB Output is correct
15 Correct 210 ms 6004 KB Output is correct
16 Correct 231 ms 5192 KB Output is correct
17 Correct 217 ms 5260 KB Output is correct
18 Correct 167 ms 6984 KB Output is correct
19 Correct 176 ms 4060 KB Output is correct
20 Correct 228 ms 5692 KB Output is correct
21 Runtime error 2 ms 848 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -