Submission #729404

# Submission time Handle Problem Language Result Execution time Memory
729404 2023-04-24T03:34:41 Z pcc Snake Escaping (JOI18_snake_escaping) C++14
5 / 100
2000 ms 5260 KB
#include <bits/stdc++.h>
using namespace std;

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


void solve(){
	int n,q;
	cin>>n>>q;
	int arr[1<<n];
	for(auto &i:arr){
		char c;
		cin>>c;
		i = c-'0';
	}
	while(q--){
		string s;
		cin>>s;
		reverse(s.begin(),s.end());
		int ans = 0;
		for(int j = 0;j<(1<<n);j++){
			bool flag = true;
			for(int k = 0;k<n;k++){
				if(s[k] == '0'&&((1<<k)&j))flag = false;
				else if(s[k] == '1'&&!((1<<k)&j))flag = false;
			}
			if(flag)ans += arr[j];//cout<<j<<' ';
		}
		cout<<ans<<'\n';
	}
	return;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	while(t--)solve();
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 212 KB Output is correct
2 Correct 13 ms 212 KB Output is correct
3 Correct 14 ms 336 KB Output is correct
4 Correct 15 ms 332 KB Output is correct
5 Correct 14 ms 212 KB Output is correct
6 Correct 14 ms 328 KB Output is correct
7 Correct 14 ms 328 KB Output is correct
8 Correct 11 ms 340 KB Output is correct
9 Correct 11 ms 212 KB Output is correct
10 Correct 16 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 212 KB Output is correct
2 Correct 13 ms 212 KB Output is correct
3 Correct 14 ms 336 KB Output is correct
4 Correct 15 ms 332 KB Output is correct
5 Correct 14 ms 212 KB Output is correct
6 Correct 14 ms 328 KB Output is correct
7 Correct 14 ms 328 KB Output is correct
8 Correct 11 ms 340 KB Output is correct
9 Correct 11 ms 212 KB Output is correct
10 Correct 16 ms 212 KB Output is correct
11 Execution timed out 2057 ms 1436 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 212 KB Output is correct
2 Correct 13 ms 212 KB Output is correct
3 Correct 14 ms 336 KB Output is correct
4 Correct 15 ms 332 KB Output is correct
5 Correct 14 ms 212 KB Output is correct
6 Correct 14 ms 328 KB Output is correct
7 Correct 14 ms 328 KB Output is correct
8 Correct 11 ms 340 KB Output is correct
9 Correct 11 ms 212 KB Output is correct
10 Correct 16 ms 212 KB Output is correct
11 Execution timed out 2057 ms 1436 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 212 KB Output is correct
2 Correct 13 ms 212 KB Output is correct
3 Correct 14 ms 336 KB Output is correct
4 Correct 15 ms 332 KB Output is correct
5 Correct 14 ms 212 KB Output is correct
6 Correct 14 ms 328 KB Output is correct
7 Correct 14 ms 328 KB Output is correct
8 Correct 11 ms 340 KB Output is correct
9 Correct 11 ms 212 KB Output is correct
10 Correct 16 ms 212 KB Output is correct
11 Execution timed out 2045 ms 5260 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 212 KB Output is correct
2 Correct 13 ms 212 KB Output is correct
3 Correct 14 ms 336 KB Output is correct
4 Correct 15 ms 332 KB Output is correct
5 Correct 14 ms 212 KB Output is correct
6 Correct 14 ms 328 KB Output is correct
7 Correct 14 ms 328 KB Output is correct
8 Correct 11 ms 340 KB Output is correct
9 Correct 11 ms 212 KB Output is correct
10 Correct 16 ms 212 KB Output is correct
11 Execution timed out 2057 ms 1436 KB Time limit exceeded
12 Halted 0 ms 0 KB -