Submission #943284

#TimeUsernameProblemLanguageResultExecution timeMemory
943284guechotjrhhSnake Escaping (JOI18_snake_escaping)C++14
5 / 100
2031 ms14980 KiB
#include<iostream> #include<string> using namespace std; string str; int n; void init(int N, int Q, string S) { n = N; str = S; } int query(string A) { int ones = 0, zeros = 0; for (int i = 0; i < n; i++) { if (A[n-1-i] == '1') { ones += (1 << i); } if (A[n-1-i] == '0') { zeros += (1 << i); } } int res = 0; for (int i = 0; i < (1 << n); i++) { if (i & zeros) continue; if ((~i) & ones) continue; res += str[i] - '0'; } return res; } 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...