# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115987 | 2019-06-10T06:38:40 Z | oolimry | Snake Escaping (JOI18_snake_escaping) | C++14 | 2000 ms | 6272 KB |
#include <bits/stdc++.h> using namespace std; int value[200000]; unordered_map<string,int> memo; int n , q; int dp(string 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 | 8 ms | 512 KB | Output is correct |
2 | Correct | 13 ms | 764 KB | Output is correct |
3 | Correct | 4 ms | 640 KB | Output is correct |
4 | Correct | 5 ms | 640 KB | Output is correct |
5 | Correct | 20 ms | 1236 KB | Output is correct |
6 | Correct | 7 ms | 1024 KB | Output is correct |
7 | Correct | 7 ms | 1024 KB | Output is correct |
8 | Correct | 144 ms | 512 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 14 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 512 KB | Output is correct |
2 | Correct | 13 ms | 764 KB | Output is correct |
3 | Correct | 4 ms | 640 KB | Output is correct |
4 | Correct | 5 ms | 640 KB | Output is correct |
5 | Correct | 20 ms | 1236 KB | Output is correct |
6 | Correct | 7 ms | 1024 KB | Output is correct |
7 | Correct | 7 ms | 1024 KB | Output is correct |
8 | Correct | 144 ms | 512 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 14 ms | 768 KB | Output is correct |
11 | Execution timed out | 2037 ms | 6272 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 512 KB | Output is correct |
2 | Correct | 13 ms | 764 KB | Output is correct |
3 | Correct | 4 ms | 640 KB | Output is correct |
4 | Correct | 5 ms | 640 KB | Output is correct |
5 | Correct | 20 ms | 1236 KB | Output is correct |
6 | Correct | 7 ms | 1024 KB | Output is correct |
7 | Correct | 7 ms | 1024 KB | Output is correct |
8 | Correct | 144 ms | 512 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 14 ms | 768 KB | Output is correct |
11 | Execution timed out | 2037 ms | 6272 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 512 KB | Output is correct |
2 | Correct | 13 ms | 764 KB | Output is correct |
3 | Correct | 4 ms | 640 KB | Output is correct |
4 | Correct | 5 ms | 640 KB | Output is correct |
5 | Correct | 20 ms | 1236 KB | Output is correct |
6 | Correct | 7 ms | 1024 KB | Output is correct |
7 | Correct | 7 ms | 1024 KB | Output is correct |
8 | Correct | 144 ms | 512 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 14 ms | 768 KB | Output is correct |
11 | Runtime error | 9 ms | 5668 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 | 8 ms | 512 KB | Output is correct |
2 | Correct | 13 ms | 764 KB | Output is correct |
3 | Correct | 4 ms | 640 KB | Output is correct |
4 | Correct | 5 ms | 640 KB | Output is correct |
5 | Correct | 20 ms | 1236 KB | Output is correct |
6 | Correct | 7 ms | 1024 KB | Output is correct |
7 | Correct | 7 ms | 1024 KB | Output is correct |
8 | Correct | 144 ms | 512 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 14 ms | 768 KB | Output is correct |
11 | Execution timed out | 2037 ms | 6272 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |