Submission #1104381

#TimeUsernameProblemLanguageResultExecution timeMemory
1104381zephyrionSnake Escaping (JOI18_snake_escaping)C++17
5 / 100
2052 ms10084 KiB
#include <bits/stdc++.h> using namespace std; int n, q; string s; int solve(const string& t, int qm) { int sum = 0; for (int i = 0; i < (1 << qm); i++) { int c = 0; int idx = 0; for (int j = 0; j < n; j++) { if (t[j] == '1') { c += 1 << j; } if (t[j] == '?') { if (i & (1 << idx)) { c += 1 << j; } idx++; } } sum += (s[c] - '0'); } return sum; } int main() { cin >> n >> q; cin >> s; while (q--) { string t; cin >> t; reverse(t.begin(), t.end()); cout << solve(t, count(t.begin(), t.end(), '?')) << 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...