# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115988 | 2019-06-10T06:39:23 Z | oolimry | Snake Escaping (JOI18_snake_escaping) | C++14 | 1709 ms | 65536 KB |
#include <bits/stdc++.h> using namespace std; int value[200000]; unordered_map<string,int> memo; int n , q; int dp(string s){ if(memo.find(s) != memo.end()) return memo[s]; for(int i = 0;i < n;i++){ if(s[i] == '?'){ string s0 = s; string s1 = s; s0[i] = '0'; s1[i] = '1'; int ans = dp(s0) + dp(s1); //cout << s << " " << ans << "\n"; memo[s] = ans; return ans; } } int v = 0; for(int i = 0;i < n;i++){ v *= 2; if(s[i] == '1') v++; } //cout << s << " " << value[v] << "\n"; memo[s] = value[v]; return value[v]; } int main() { //freopen("i.txt","r",stdin); ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> q; string s; cin >> s; for(int i = 0;i < s.length();i++){ value[i] = s[i] - '0'; } for(int qq = 0;qq < q;qq++){ cin >> s; cout << dp(s) << "\n"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 640 KB | Output is correct |
2 | Correct | 4 ms | 768 KB | Output is correct |
3 | Correct | 4 ms | 640 KB | Output is correct |
4 | Correct | 4 ms | 768 KB | Output is correct |
5 | Correct | 8 ms | 1280 KB | Output is correct |
6 | Correct | 5 ms | 896 KB | Output is correct |
7 | Correct | 6 ms | 1024 KB | Output is correct |
8 | Correct | 3 ms | 640 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 640 KB | Output is correct |
2 | Correct | 4 ms | 768 KB | Output is correct |
3 | Correct | 4 ms | 640 KB | Output is correct |
4 | Correct | 4 ms | 768 KB | Output is correct |
5 | Correct | 8 ms | 1280 KB | Output is correct |
6 | Correct | 5 ms | 896 KB | Output is correct |
7 | Correct | 6 ms | 1024 KB | Output is correct |
8 | Correct | 3 ms | 640 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 768 KB | Output is correct |
11 | Correct | 221 ms | 11208 KB | Output is correct |
12 | Correct | 261 ms | 15224 KB | Output is correct |
13 | Correct | 294 ms | 14784 KB | Output is correct |
14 | Correct | 280 ms | 15080 KB | Output is correct |
15 | Correct | 283 ms | 16760 KB | Output is correct |
16 | Correct | 331 ms | 16500 KB | Output is correct |
17 | Correct | 499 ms | 18864 KB | Output is correct |
18 | Correct | 197 ms | 16220 KB | Output is correct |
19 | Correct | 208 ms | 13184 KB | Output is correct |
20 | Correct | 242 ms | 15304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 640 KB | Output is correct |
2 | Correct | 4 ms | 768 KB | Output is correct |
3 | Correct | 4 ms | 640 KB | Output is correct |
4 | Correct | 4 ms | 768 KB | Output is correct |
5 | Correct | 8 ms | 1280 KB | Output is correct |
6 | Correct | 5 ms | 896 KB | Output is correct |
7 | Correct | 6 ms | 1024 KB | Output is correct |
8 | Correct | 3 ms | 640 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 768 KB | Output is correct |
11 | Correct | 221 ms | 11208 KB | Output is correct |
12 | Correct | 261 ms | 15224 KB | Output is correct |
13 | Correct | 294 ms | 14784 KB | Output is correct |
14 | Correct | 280 ms | 15080 KB | Output is correct |
15 | Correct | 283 ms | 16760 KB | Output is correct |
16 | Correct | 331 ms | 16500 KB | Output is correct |
17 | Correct | 499 ms | 18864 KB | Output is correct |
18 | Correct | 197 ms | 16220 KB | Output is correct |
19 | Correct | 208 ms | 13184 KB | Output is correct |
20 | Correct | 242 ms | 15304 KB | Output is correct |
21 | Correct | 286 ms | 20696 KB | Output is correct |
22 | Correct | 451 ms | 23008 KB | Output is correct |
23 | Correct | 1186 ms | 41476 KB | Output is correct |
24 | Correct | 961 ms | 37208 KB | Output is correct |
25 | Correct | 1118 ms | 48596 KB | Output is correct |
26 | Correct | 1709 ms | 65536 KB | Output is correct |
27 | Runtime error | 1554 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
28 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 640 KB | Output is correct |
2 | Correct | 4 ms | 768 KB | Output is correct |
3 | Correct | 4 ms | 640 KB | Output is correct |
4 | Correct | 4 ms | 768 KB | Output is correct |
5 | Correct | 8 ms | 1280 KB | Output is correct |
6 | Correct | 5 ms | 896 KB | Output is correct |
7 | Correct | 6 ms | 1024 KB | Output is correct |
8 | Correct | 3 ms | 640 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 768 KB | Output is correct |
11 | Runtime error | 9 ms | 4772 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 640 KB | Output is correct |
2 | Correct | 4 ms | 768 KB | Output is correct |
3 | Correct | 4 ms | 640 KB | Output is correct |
4 | Correct | 4 ms | 768 KB | Output is correct |
5 | Correct | 8 ms | 1280 KB | Output is correct |
6 | Correct | 5 ms | 896 KB | Output is correct |
7 | Correct | 6 ms | 1024 KB | Output is correct |
8 | Correct | 3 ms | 640 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 768 KB | Output is correct |
11 | Correct | 221 ms | 11208 KB | Output is correct |
12 | Correct | 261 ms | 15224 KB | Output is correct |
13 | Correct | 294 ms | 14784 KB | Output is correct |
14 | Correct | 280 ms | 15080 KB | Output is correct |
15 | Correct | 283 ms | 16760 KB | Output is correct |
16 | Correct | 331 ms | 16500 KB | Output is correct |
17 | Correct | 499 ms | 18864 KB | Output is correct |
18 | Correct | 197 ms | 16220 KB | Output is correct |
19 | Correct | 208 ms | 13184 KB | Output is correct |
20 | Correct | 242 ms | 15304 KB | Output is correct |
21 | Correct | 286 ms | 20696 KB | Output is correct |
22 | Correct | 451 ms | 23008 KB | Output is correct |
23 | Correct | 1186 ms | 41476 KB | Output is correct |
24 | Correct | 961 ms | 37208 KB | Output is correct |
25 | Correct | 1118 ms | 48596 KB | Output is correct |
26 | Correct | 1709 ms | 65536 KB | Output is correct |
27 | Runtime error | 1554 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
28 | Halted | 0 ms | 0 KB | - |