Submission #590266

#TimeUsernameProblemLanguageResultExecution timeMemory
590266blueSnake Escaping (JOI18_snake_escaping)C++17
5 / 100
2065 ms11196 KiB
#include <iostream> #include <vector> using namespace std; using vi = vector<int>; int main() { int L, Q; cin >> L >> Q; vi A((1<<L)); for(int i = 0; i < (1<<L); i++) { char c; cin >> c; A[i] = c - '0'; } for(int j = 0; j < Q; j++) { int res = 0; int mask = 0, test = 0; for(int b = L-1; b >= 0; b--) { char c; cin >> c; if(c == '0') test |= (1<<b); else if(c == '1') { mask |= (1<<b); test |= (1<<b); } } // cerr << test << ' ' << mask << '\n'; for(int i = 0; i < (1<<L); i++) { if((i & test) == mask) res += A[i]; } cout << res << '\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...