Submission #136383

#TimeUsernameProblemLanguageResultExecution timeMemory
136383KLPPSnake Escaping (JOI18_snake_escaping)C++14
5 / 100
2040 ms13280 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int lld; #define rep(i,a,b) for(int i=a;i<b;i++) int answer[(1<<10)][(1<<10)]; int main(){ int l,q; cin>>l>>q; string R; cin>>R; rep(i,0,(1<<10)){ rep(j,0,(1<<10)){ answer[i][j]=-1; } } while(q--){ string s; cin>>s; int b,t; b=0; t=0; rep(i,0,l){ if(s[i]=='1'){ b+=(1<<(l-1-i)); t+=(1<<(l-1-i)); } if(s[i]=='?'){ t+=(1<<(l-1-i)); } } if(answer[b][t]!=-1)cout<<answer[b][t]<<endl; else{ answer[b][t]=0; rep(i,0,(1<<l)){ if(((i&b)==b) && ((i&t)==i)){ //cout<<b<<" "<<t<<" "<<i<<" "<<R[i]<<endl; answer[b][t]+=R[i]-'0'; } } cout<<answer[b][t]<<endl; } } return 0; }
#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...