Submission #287545

#TimeUsernameProblemLanguageResultExecution timeMemory
287545Leonardo_PaesSnake Escaping (JOI18_snake_escaping)C++17
12 / 100
308 ms65536 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 13; int dp[(1<<maxn)][(1<<maxn)]; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int l, q; cin >> l >> q; vector<int> v((1<<l)); for(int i=0; i<(1<<l); i++){ char a; cin >> a; v[i] = a - '0'; } for(int a=(1<<l)-1; a>=0; a--){ dp[a][0] = v[a]; // caso base -> ok for(int b=1; b<(1<<l); b++){ int x = (b & -b); // rightmost set bit tipo na BIT -> ok dp[a][b] = dp[a|x][b^x] + dp[a][b^x]; // unicos dois casos -> ok } } while(q--){ string s; cin >> s; int a = 0, b = 0; for(int i=0; i<l; i++){ if(s[i] == '1') a += (1<<(l-i-1)); if(s[i] == '?') b += (1<<(l-i-1)); } cout << dp[a][b] << "\n"; } 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...