답안 #708995

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708995 2023-03-13T03:41:41 Z myrcella Snake Escaping (JOI18_snake_escaping) C++17
12 / 100
2000 ms 5892 KB
//by szh
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

int L,Q;
int ans[2000010];
string s;
int pw[14];

int main() {
//	freopen("input.txt","r",stdin);	
	std::ios::sync_with_stdio(false);cin.tie(0);
	pw[0]=1;
	rep(i,1,14) pw[i] = pw[i-1]*3;
	cin>>L>>Q;
	cin>>s;
	rep(i,0,(1<<L)) {
		int cur = (int)(s[i]-'0');
		rep(mask,0,(1<<L)) {
			int val = 0;
			rep(j,0,L) {
				if ((mask>>j)&1) val+=2*pw[j];
				else val += ((i>>j)&1)*pw[j];
			}
			ans[val] += cur;
		}
	}
	while (Q--) {
		string ss;cin>>ss;
		int mask = 0;
		rep(i,0,L) {
			if (ss[L-1-i]=='1') mask+=pw[i];
			else if (ss[L-1-i]=='?') mask+=pw[i]*2;
		}
		cout<<ans[mask]<<"\n";
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 468 KB Output is correct
2 Correct 18 ms 504 KB Output is correct
3 Correct 17 ms 468 KB Output is correct
4 Correct 17 ms 560 KB Output is correct
5 Correct 18 ms 464 KB Output is correct
6 Correct 17 ms 576 KB Output is correct
7 Correct 17 ms 468 KB Output is correct
8 Correct 19 ms 468 KB Output is correct
9 Correct 18 ms 576 KB Output is correct
10 Correct 17 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 468 KB Output is correct
2 Correct 18 ms 504 KB Output is correct
3 Correct 17 ms 468 KB Output is correct
4 Correct 17 ms 560 KB Output is correct
5 Correct 18 ms 464 KB Output is correct
6 Correct 17 ms 576 KB Output is correct
7 Correct 17 ms 468 KB Output is correct
8 Correct 19 ms 468 KB Output is correct
9 Correct 18 ms 576 KB Output is correct
10 Correct 17 ms 468 KB Output is correct
11 Correct 195 ms 4732 KB Output is correct
12 Correct 206 ms 4424 KB Output is correct
13 Correct 207 ms 3660 KB Output is correct
14 Correct 217 ms 3668 KB Output is correct
15 Correct 195 ms 4716 KB Output is correct
16 Correct 210 ms 4024 KB Output is correct
17 Correct 224 ms 3788 KB Output is correct
18 Correct 156 ms 5836 KB Output is correct
19 Correct 201 ms 2648 KB Output is correct
20 Correct 198 ms 4428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 468 KB Output is correct
2 Correct 18 ms 504 KB Output is correct
3 Correct 17 ms 468 KB Output is correct
4 Correct 17 ms 560 KB Output is correct
5 Correct 18 ms 464 KB Output is correct
6 Correct 17 ms 576 KB Output is correct
7 Correct 17 ms 468 KB Output is correct
8 Correct 19 ms 468 KB Output is correct
9 Correct 18 ms 576 KB Output is correct
10 Correct 17 ms 468 KB Output is correct
11 Correct 195 ms 4732 KB Output is correct
12 Correct 206 ms 4424 KB Output is correct
13 Correct 207 ms 3660 KB Output is correct
14 Correct 217 ms 3668 KB Output is correct
15 Correct 195 ms 4716 KB Output is correct
16 Correct 210 ms 4024 KB Output is correct
17 Correct 224 ms 3788 KB Output is correct
18 Correct 156 ms 5836 KB Output is correct
19 Correct 201 ms 2648 KB Output is correct
20 Correct 198 ms 4428 KB Output is correct
21 Execution timed out 2079 ms 5892 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 468 KB Output is correct
2 Correct 18 ms 504 KB Output is correct
3 Correct 17 ms 468 KB Output is correct
4 Correct 17 ms 560 KB Output is correct
5 Correct 18 ms 464 KB Output is correct
6 Correct 17 ms 576 KB Output is correct
7 Correct 17 ms 468 KB Output is correct
8 Correct 19 ms 468 KB Output is correct
9 Correct 18 ms 576 KB Output is correct
10 Correct 17 ms 468 KB Output is correct
11 Runtime error 6 ms 4600 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 468 KB Output is correct
2 Correct 18 ms 504 KB Output is correct
3 Correct 17 ms 468 KB Output is correct
4 Correct 17 ms 560 KB Output is correct
5 Correct 18 ms 464 KB Output is correct
6 Correct 17 ms 576 KB Output is correct
7 Correct 17 ms 468 KB Output is correct
8 Correct 19 ms 468 KB Output is correct
9 Correct 18 ms 576 KB Output is correct
10 Correct 17 ms 468 KB Output is correct
11 Correct 195 ms 4732 KB Output is correct
12 Correct 206 ms 4424 KB Output is correct
13 Correct 207 ms 3660 KB Output is correct
14 Correct 217 ms 3668 KB Output is correct
15 Correct 195 ms 4716 KB Output is correct
16 Correct 210 ms 4024 KB Output is correct
17 Correct 224 ms 3788 KB Output is correct
18 Correct 156 ms 5836 KB Output is correct
19 Correct 201 ms 2648 KB Output is correct
20 Correct 198 ms 4428 KB Output is correct
21 Execution timed out 2079 ms 5892 KB Time limit exceeded
22 Halted 0 ms 0 KB -