# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
968504 | 2024-04-23T13:59:29 Z | anton | Abracadabra (CEOI22_abracadabra) | C++17 | 1346 ms | 524288 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> void shuffle(vector<int> &val){ int k = val.size(); vector<deque<int>> parts(2); for(int i =0; i<val.size()/2; i++){ parts[0].push_back(val[i]); parts[1].push_back(val[i + val.size()/2]); } val.clear(); while(val.size()<k){ if(parts[0].size()==0){ val.push_back(parts[1].front()); parts[1].pop_front(); } else if(parts[1].size()==0){ val.push_back(parts[0].front()); parts[0].pop_front(); } else{ if(parts[0].front()<parts[1].front()){ val.push_back(parts[0].front()); parts[0].pop_front(); } else{ val.push_back(parts[1].front()); parts[1].pop_front(); } } } } bool stable(vector<int>& r){ int big = 0; for(int i = 0; i<r.size()/2; i++){ big = max(big, r[i]); } return r[(r.size()/2)] > big; } signed main(){ cin.tie(NULL); ios_base::sync_with_stdio(false); int n, q; cin>>n>>q; vector<int> v(n); for(int i = 0; i<n; i++){ cin>>v[i]; } vector<vector<int>> results; results.push_back(v); for(int i = 1; !stable(results.back()); i++){ results.push_back(results.back()); shuffle(results.back()); } for(int i = 0;i<q; i++){ int t, j; cin>>t>>j; if(t>=results.size()){ cout<<results.back()[j-1]<<endl; } else{ cout<<results[t][j-1]<<endl; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1346 ms | 12256 KB | Output is correct |
2 | Correct | 1268 ms | 13696 KB | Output is correct |
3 | Correct | 1265 ms | 14972 KB | Output is correct |
4 | Correct | 1191 ms | 10488 KB | Output is correct |
5 | Correct | 1248 ms | 12780 KB | Output is correct |
6 | Correct | 1252 ms | 11216 KB | Output is correct |
7 | Correct | 1277 ms | 13068 KB | Output is correct |
8 | Correct | 1165 ms | 11184 KB | Output is correct |
9 | Correct | 1171 ms | 10716 KB | Output is correct |
10 | Correct | 1205 ms | 11008 KB | Output is correct |
11 | Correct | 1209 ms | 11064 KB | Output is correct |
12 | Correct | 1211 ms | 9616 KB | Output is correct |
13 | Correct | 1177 ms | 10476 KB | Output is correct |
14 | Correct | 1199 ms | 12032 KB | Output is correct |
15 | Correct | 1198 ms | 11176 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1170 ms | 9824 KB | Output is correct |
18 | Correct | 1214 ms | 9560 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 749 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 677 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1346 ms | 12256 KB | Output is correct |
2 | Correct | 1268 ms | 13696 KB | Output is correct |
3 | Correct | 1265 ms | 14972 KB | Output is correct |
4 | Correct | 1191 ms | 10488 KB | Output is correct |
5 | Correct | 1248 ms | 12780 KB | Output is correct |
6 | Correct | 1252 ms | 11216 KB | Output is correct |
7 | Correct | 1277 ms | 13068 KB | Output is correct |
8 | Correct | 1165 ms | 11184 KB | Output is correct |
9 | Correct | 1171 ms | 10716 KB | Output is correct |
10 | Correct | 1205 ms | 11008 KB | Output is correct |
11 | Correct | 1209 ms | 11064 KB | Output is correct |
12 | Correct | 1211 ms | 9616 KB | Output is correct |
13 | Correct | 1177 ms | 10476 KB | Output is correct |
14 | Correct | 1199 ms | 12032 KB | Output is correct |
15 | Correct | 1198 ms | 11176 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1170 ms | 9824 KB | Output is correct |
18 | Correct | 1214 ms | 9560 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Runtime error | 749 ms | 524288 KB | Execution killed with signal 9 |
22 | Halted | 0 ms | 0 KB | - |