Submission #943413

#TimeUsernameProblemLanguageResultExecution timeMemory
943413guechotjrhhSnake Escaping (JOI18_snake_escaping)C++14
12 / 100
2029 ms65536 KiB
#include<iostream> #include<string> using namespace std; #include<map> #include<string> #include<algorithm> #include<vector> using namespace std; #define all(x) x.begin(),x.end() string str; int n; map<string, int> mp; string itos(int a, int l) { string res = ""; for (int i = 0; i < l; i++) { res += '0' + (a & 1); a >>= 1; } reverse(all(res)); return res; } void init(int N, int Q, string S) { n = N; str = S; for (int i = 0; i < (1 << n); i++) { for (int j = 0; j < (1 << n); j++) { string s = itos(i, n); for (int w = 0; w < n; w++) if (j & (1 << w)) s[w] = '?'; mp[s] += S[i]-'0'; } } } int query(string A) { return mp[A]; } int main() { ios::sync_with_stdio(0); cin.tie(0); int N, Q; cin >> N >> Q; string S; cin >> S; init(N, Q, move(S)); for (int i = 0; i < Q; i++) { string A; cin >> A; cout << query(move(A)) << endl; } }
#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...