제출 #1137754

#제출 시각아이디문제언어결과실행 시간메모리
1137754varun312Snake Escaping (JOI18_snake_escaping)C++20
12 / 100
2095 ms8208 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define mp make_pair #define fi first #define se second #define endl "\n" int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << fixed << setprecision(0); int l,q; cin >> l >> q; int n = (1 << l); string s; cin >> s; map<string, int> cache; while (q--) { string a; cin >> a; if (cache.find(a) != cache.end()) { cout << cache[a] << endl; continue; } int ans = 0; for (int i = 0; i < n; i++) { for (int bit = 0; bit < l; bit++) { if ((a[l-bit-1] != '?') && ((a[l-bit-1] == '1') != (bool)(i & (1 << bit)))) { // cout << "failed: " << bit << " " << (1 << bit) << " as" << i << endl; // cout << (i & (1 << bit)) << endl; goto nah; } } // cout << i << " "; ans += s[i]-'0'; nah: continue; } cache[a] = ans; cout << ans << 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...