# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642768 | 2022-09-20T13:15:20 Z | andrei_boaca | Abracadabra (CEOI22_abracadabra) | C++14 | 1306 ms | 524288 KB |
#include <bits/stdc++.h> using namespace std; int n,q; vector<int> v; vector<vector<int>> vals; vector<int> trans(vector<int> v) { vector<int> a,b; for(int i=0;i<v.size();i++) { if(i*2<v.size()) a.push_back(v[i]); else b.push_back(v[i]); } reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); vector<int> rez; while(a.size()||b.size()) { if(a.size()&&b.size()) { int x=a.back(); int y=b.back(); rez.push_back(min(x,y)); if(x<y) a.pop_back(); else b.pop_back(); continue; } if(a.size()) { int x=a.back(); a.pop_back(); rez.push_back(x); } else { int x=b.back(); b.pop_back(); rez.push_back(x); } } return rez; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>q; for(int i=1;i<=n;i++) { int x; cin>>x; v.push_back(x); } vals.push_back(v); while(true) { v=trans(v); vector<int> aux=vals.back(); bool iseq=1; for(int i=0;i<v.size();i++) if(v[i]!=aux[i]) iseq=0; if(iseq) break; vals.push_back(v); } while(q--) { int i,j; cin>>i>>j; int lg=vals.size(); i=min(i,lg-1); cout<<vals[i][j-1]<<'\n'; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 262 ms | 9408 KB | Output is correct |
2 | Correct | 200 ms | 8824 KB | Output is correct |
3 | Correct | 228 ms | 9380 KB | Output is correct |
4 | Correct | 177 ms | 10196 KB | Output is correct |
5 | Correct | 200 ms | 10636 KB | Output is correct |
6 | Correct | 200 ms | 9932 KB | Output is correct |
7 | Correct | 204 ms | 9676 KB | Output is correct |
8 | Correct | 194 ms | 9180 KB | Output is correct |
9 | Correct | 174 ms | 9368 KB | Output is correct |
10 | Correct | 196 ms | 9048 KB | Output is correct |
11 | Correct | 182 ms | 9036 KB | Output is correct |
12 | Correct | 176 ms | 8408 KB | Output is correct |
13 | Correct | 179 ms | 8456 KB | Output is correct |
14 | Correct | 199 ms | 10928 KB | Output is correct |
15 | Correct | 182 ms | 10440 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 203 ms | 9420 KB | Output is correct |
18 | Correct | 172 ms | 9336 KB | Output is correct |
19 | Correct | 1 ms | 324 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1306 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1246 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 262 ms | 9408 KB | Output is correct |
2 | Correct | 200 ms | 8824 KB | Output is correct |
3 | Correct | 228 ms | 9380 KB | Output is correct |
4 | Correct | 177 ms | 10196 KB | Output is correct |
5 | Correct | 200 ms | 10636 KB | Output is correct |
6 | Correct | 200 ms | 9932 KB | Output is correct |
7 | Correct | 204 ms | 9676 KB | Output is correct |
8 | Correct | 194 ms | 9180 KB | Output is correct |
9 | Correct | 174 ms | 9368 KB | Output is correct |
10 | Correct | 196 ms | 9048 KB | Output is correct |
11 | Correct | 182 ms | 9036 KB | Output is correct |
12 | Correct | 176 ms | 8408 KB | Output is correct |
13 | Correct | 179 ms | 8456 KB | Output is correct |
14 | Correct | 199 ms | 10928 KB | Output is correct |
15 | Correct | 182 ms | 10440 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 203 ms | 9420 KB | Output is correct |
18 | Correct | 172 ms | 9336 KB | Output is correct |
19 | Correct | 1 ms | 324 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Runtime error | 1306 ms | 524288 KB | Execution killed with signal 9 |
22 | Halted | 0 ms | 0 KB | - |