Submission #376466

#TimeUsernameProblemLanguageResultExecution timeMemory
376466astoriaSnake Escaping (JOI18_snake_escaping)C++14
12 / 100
2072 ms11292 KiB
#include "bits/stdc++.h" using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int l,q,n; cin>>l>>q; n=1<<l; string s; cin>>s; int tox[n]; for(int i=0; i<n; i++) tox[i] = s[i]-'0'; int pw[l+5]; pw[0]=1; int k=1; for(int i=1; i<=l; i++){ k*=3; pw[i]=k;} int ans[k]; memset(ans,0,sizeof(ans)); for(int ahc=0; ahc<k; ahc++){ vector<int> v; int cr=ahc; for(int j=0; j<l; j++){ v.push_back(cr%3); cr/=3; } for(int i=0; i<n; i++){ bitset<13> b(i); bool f=1; for(int j=0; j<l; j++){ if(v[j]!=2 && (b[j]!=v[j])){ f=0; break;} } if(f) ans[ahc] += tox[i]; } } for(int ahc=0; ahc<q; ahc++){ string s; cin>>s; int qr=0; for(int i=0; i<l; i++){ int pwer = l-i-1; if(s[i]=='1') qr += (pw[pwer]); if(s[i]=='?') qr += (2*pw[pwer]); } cout<<ans[qr]<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...