# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1115418 | 2024-11-20T12:48:55 Z | staszic_ojuz | Snake Escaping (JOI18_snake_escaping) | C++17 | 640 ms | 65536 KB |
#include <bits/stdc++.h> using namespace std; vector<int> tox; unordered_map<string,int> m; unordered_map<string,bool> ch; int l; int pot(int n) { if(n ==0) return 1; return 2*pot(n-1); } long long tox_ans(string c) { if(ch[c]) return m[c]; ch[c] = true; string a = c,b = c; m[c] = 0; bool t = false; for(int i = 0;i<l;i++) { if(c[i] == '?') { t = true; a[i] = '0'; b[i] = '1'; m[c] = tox_ans(a) + tox_ans(b); a[i] = '?'; b[i] = '?'; } } if(t) return m[c]; int ans = 0; for(int i = 0;i<l;i++) { if(c[i] == '1') { ans+=pot(l-i-1); } } m[c] = tox[ans]; return tox[ans]; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>l; int q; cin>>q; string s; cin>>s; tox.resize(pot(l)); for(int i = 0 ;i<pot(l);i++) { if(s[i] == '0') tox[i] = 0; if(s[i] == '1') tox[i] = 1; if(s[i] == '2') tox[i] = 2; if(s[i] == '3') tox[i] = 3; if(s[i] == '4') tox[i] = 4; if(s[i] == '5') tox[i] = 5; if(s[i] == '6') tox[i] = 6; if(s[i] == '7') tox[i] = 7; if(s[i] == '8') tox[i] = 8; if(s[i] == '9') tox[i] = 9; } string start; for(int i = 0;i<l;i++) { start += '?'; } int x =tox_ans(start); for(int i = 0;i<q;i++) { string c; cin>>c; cout<<m[c]<<"\n"; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 9064 KB | Output is correct |
2 | Correct | 51 ms | 9072 KB | Output is correct |
3 | Correct | 49 ms | 8956 KB | Output is correct |
4 | Correct | 52 ms | 9064 KB | Output is correct |
5 | Correct | 53 ms | 9064 KB | Output is correct |
6 | Correct | 50 ms | 9076 KB | Output is correct |
7 | Correct | 52 ms | 9064 KB | Output is correct |
8 | Correct | 51 ms | 9064 KB | Output is correct |
9 | Correct | 51 ms | 9120 KB | Output is correct |
10 | Correct | 53 ms | 9064 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 9064 KB | Output is correct |
2 | Correct | 51 ms | 9072 KB | Output is correct |
3 | Correct | 49 ms | 8956 KB | Output is correct |
4 | Correct | 52 ms | 9064 KB | Output is correct |
5 | Correct | 53 ms | 9064 KB | Output is correct |
6 | Correct | 50 ms | 9076 KB | Output is correct |
7 | Correct | 52 ms | 9064 KB | Output is correct |
8 | Correct | 51 ms | 9064 KB | Output is correct |
9 | Correct | 51 ms | 9120 KB | Output is correct |
10 | Correct | 53 ms | 9064 KB | Output is correct |
11 | Correct | 200 ms | 22888 KB | Output is correct |
12 | Correct | 214 ms | 19560 KB | Output is correct |
13 | Correct | 237 ms | 22632 KB | Output is correct |
14 | Correct | 244 ms | 18280 KB | Output is correct |
15 | Correct | 223 ms | 22376 KB | Output is correct |
16 | Correct | 286 ms | 18792 KB | Output is correct |
17 | Correct | 273 ms | 14952 KB | Output is correct |
18 | Correct | 182 ms | 21608 KB | Output is correct |
19 | Correct | 182 ms | 21792 KB | Output is correct |
20 | Correct | 215 ms | 23144 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 9064 KB | Output is correct |
2 | Correct | 51 ms | 9072 KB | Output is correct |
3 | Correct | 49 ms | 8956 KB | Output is correct |
4 | Correct | 52 ms | 9064 KB | Output is correct |
5 | Correct | 53 ms | 9064 KB | Output is correct |
6 | Correct | 50 ms | 9076 KB | Output is correct |
7 | Correct | 52 ms | 9064 KB | Output is correct |
8 | Correct | 51 ms | 9064 KB | Output is correct |
9 | Correct | 51 ms | 9120 KB | Output is correct |
10 | Correct | 53 ms | 9064 KB | Output is correct |
11 | Correct | 200 ms | 22888 KB | Output is correct |
12 | Correct | 214 ms | 19560 KB | Output is correct |
13 | Correct | 237 ms | 22632 KB | Output is correct |
14 | Correct | 244 ms | 18280 KB | Output is correct |
15 | Correct | 223 ms | 22376 KB | Output is correct |
16 | Correct | 286 ms | 18792 KB | Output is correct |
17 | Correct | 273 ms | 14952 KB | Output is correct |
18 | Correct | 182 ms | 21608 KB | Output is correct |
19 | Correct | 182 ms | 21792 KB | Output is correct |
20 | Correct | 215 ms | 23144 KB | Output is correct |
21 | Runtime error | 640 ms | 65536 KB | Execution killed with signal 9 |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 9064 KB | Output is correct |
2 | Correct | 51 ms | 9072 KB | Output is correct |
3 | Correct | 49 ms | 8956 KB | Output is correct |
4 | Correct | 52 ms | 9064 KB | Output is correct |
5 | Correct | 53 ms | 9064 KB | Output is correct |
6 | Correct | 50 ms | 9076 KB | Output is correct |
7 | Correct | 52 ms | 9064 KB | Output is correct |
8 | Correct | 51 ms | 9064 KB | Output is correct |
9 | Correct | 51 ms | 9120 KB | Output is correct |
10 | Correct | 53 ms | 9064 KB | Output is correct |
11 | Runtime error | 518 ms | 65536 KB | Execution killed with signal 9 |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 9064 KB | Output is correct |
2 | Correct | 51 ms | 9072 KB | Output is correct |
3 | Correct | 49 ms | 8956 KB | Output is correct |
4 | Correct | 52 ms | 9064 KB | Output is correct |
5 | Correct | 53 ms | 9064 KB | Output is correct |
6 | Correct | 50 ms | 9076 KB | Output is correct |
7 | Correct | 52 ms | 9064 KB | Output is correct |
8 | Correct | 51 ms | 9064 KB | Output is correct |
9 | Correct | 51 ms | 9120 KB | Output is correct |
10 | Correct | 53 ms | 9064 KB | Output is correct |
11 | Correct | 200 ms | 22888 KB | Output is correct |
12 | Correct | 214 ms | 19560 KB | Output is correct |
13 | Correct | 237 ms | 22632 KB | Output is correct |
14 | Correct | 244 ms | 18280 KB | Output is correct |
15 | Correct | 223 ms | 22376 KB | Output is correct |
16 | Correct | 286 ms | 18792 KB | Output is correct |
17 | Correct | 273 ms | 14952 KB | Output is correct |
18 | Correct | 182 ms | 21608 KB | Output is correct |
19 | Correct | 182 ms | 21792 KB | Output is correct |
20 | Correct | 215 ms | 23144 KB | Output is correct |
21 | Runtime error | 640 ms | 65536 KB | Execution killed with signal 9 |
22 | Halted | 0 ms | 0 KB | - |