Submission #956170

#TimeUsernameProblemLanguageResultExecution timeMemory
956170samvar_0907Snake Escaping (JOI18_snake_escaping)C++17
5 / 100
2057 ms5280 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int l, q; cin >> l >> q; string toxicities; cin >> toxicities; while (q--){ string s; cin >> s; int ans = 0; for (int bm = 0; bm < (1 << l); bm++){ bool add = true; for (int i = l - 1; i >= 0; i--){ if (s[i] == '0' || s[i] == '1'){ int s_digit = s[i] - '0'; int bm_bit = (bm >> (l - i - 1)) & 1; if (s_digit != bm_bit) { add = false; break; } } } if (add){ ans += toxicities[bm]-'0'; } } cout << ans << endl; } 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...