답안 #333904

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333904 2020-12-08T02:47:28 Z YJU Snake Escaping (JOI18_snake_escaping) C++14
12 / 100
271 ms 16620 KB
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=4e5+5;
const ll K=350;
const ld pi=acos(-1);
const ll INF=(1LL<<60);
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()

ll dp[N],l,po[N],q,k;
string s,a;

ll get3(ll val,ll ip){
	return (val/po[ip])%3;
}

void cal(ll id){
	REP(i,po[k]){
		ll tx=0;
		REP(j,k){
			if(get3(i,k-j-1)==2){
				dp[i]=dp[i-2*po[k-j-1]]+dp[i-po[k-j-1]];
				break;
			}
			tx=tx*2+get3(i,k-j-1);
			if(j==k-1){dp[i]=s[(id<<k)+tx]-'0';}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>l>>q>>s;
	k=min(l,13LL);
	po[0]=1;
	REP1(i,k)po[i]=po[i-1]*3;
	cal(0);
	while(q--){
		cin>>a;
		ll tx=0;
		REP(i,SZ(a))tx=tx*3+(a[i]=='?'?2:a[i]-'0');
		cout<<dp[tx]<<"\n";
	}
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 876 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 2 ms 876 KB Output is correct
4 Correct 2 ms 876 KB Output is correct
5 Correct 2 ms 876 KB Output is correct
6 Correct 2 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 2 ms 876 KB Output is correct
9 Correct 2 ms 876 KB Output is correct
10 Correct 3 ms 876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 876 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 2 ms 876 KB Output is correct
4 Correct 2 ms 876 KB Output is correct
5 Correct 2 ms 876 KB Output is correct
6 Correct 2 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 2 ms 876 KB Output is correct
9 Correct 2 ms 876 KB Output is correct
10 Correct 3 ms 876 KB Output is correct
11 Correct 230 ms 15724 KB Output is correct
12 Correct 271 ms 15212 KB Output is correct
13 Correct 227 ms 14564 KB Output is correct
14 Correct 228 ms 14700 KB Output is correct
15 Correct 240 ms 15596 KB Output is correct
16 Correct 237 ms 14700 KB Output is correct
17 Correct 250 ms 14700 KB Output is correct
18 Correct 195 ms 16620 KB Output is correct
19 Correct 192 ms 13676 KB Output is correct
20 Correct 244 ms 15212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 876 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 2 ms 876 KB Output is correct
4 Correct 2 ms 876 KB Output is correct
5 Correct 2 ms 876 KB Output is correct
6 Correct 2 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 2 ms 876 KB Output is correct
9 Correct 2 ms 876 KB Output is correct
10 Correct 3 ms 876 KB Output is correct
11 Correct 230 ms 15724 KB Output is correct
12 Correct 271 ms 15212 KB Output is correct
13 Correct 227 ms 14564 KB Output is correct
14 Correct 228 ms 14700 KB Output is correct
15 Correct 240 ms 15596 KB Output is correct
16 Correct 237 ms 14700 KB Output is correct
17 Correct 250 ms 14700 KB Output is correct
18 Correct 195 ms 16620 KB Output is correct
19 Correct 192 ms 13676 KB Output is correct
20 Correct 244 ms 15212 KB Output is correct
21 Runtime error 18 ms 7404 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 876 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 2 ms 876 KB Output is correct
4 Correct 2 ms 876 KB Output is correct
5 Correct 2 ms 876 KB Output is correct
6 Correct 2 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 2 ms 876 KB Output is correct
9 Correct 2 ms 876 KB Output is correct
10 Correct 3 ms 876 KB Output is correct
11 Runtime error 22 ms 10768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 876 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 2 ms 876 KB Output is correct
4 Correct 2 ms 876 KB Output is correct
5 Correct 2 ms 876 KB Output is correct
6 Correct 2 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 2 ms 876 KB Output is correct
9 Correct 2 ms 876 KB Output is correct
10 Correct 3 ms 876 KB Output is correct
11 Correct 230 ms 15724 KB Output is correct
12 Correct 271 ms 15212 KB Output is correct
13 Correct 227 ms 14564 KB Output is correct
14 Correct 228 ms 14700 KB Output is correct
15 Correct 240 ms 15596 KB Output is correct
16 Correct 237 ms 14700 KB Output is correct
17 Correct 250 ms 14700 KB Output is correct
18 Correct 195 ms 16620 KB Output is correct
19 Correct 192 ms 13676 KB Output is correct
20 Correct 244 ms 15212 KB Output is correct
21 Runtime error 18 ms 7404 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -