Submission #680348

#TimeUsernameProblemLanguageResultExecution timeMemory
680348vjudge1Snake Escaping (JOI18_snake_escaping)C++17
5 / 100
2083 ms6188 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define sz(x) (int)x.size() #define getBit(x, i) ((x) >> (i) & 1) #define rep(i, begin, end) for (ll i = (begin); i <= (end); i++) #define rrep(i, begin, end) for (ll i = (begin); i >= (end); i--) typedef long long ll; typedef pair<ll, ll> ii; template <class T> bool minimize(T &a, const T &b) { if(a > b) {a = b; return 1;} return 0; } template <class T> bool maximize(T &a, const T &b) { if(a < b) {a = b; return 1;} return 0; } const int N = 1e5 + 7; int n, q; ll f[1 << 13]; char t[N]; int toxic[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); // freopen("test.inp", "r", stdin); // freopen("test.out", "w", stdout); cin >> n >> q >> t; rep(i, 0, (1 << n) - 1) toxic[i] = t[i] - '0'; while (q--) { string s; cin >> s; ll ans = 0; rep(i, 0, (1 << n) - 1) { bool ok = 1; rep(j, 0, n - 1) { if (s[j] != '?' && (s[j] - '0') != getBit(i, n - 1 - j)) { ok = 0; break; } } if (ok) ans += toxic[i]; } cout << ans << '\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...