제출 #1182986

#제출 시각아이디문제언어결과실행 시간메모리
1182986domblyAbracadabra (CEOI22_abracadabra)C++20
10 / 100
3090 ms20204 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; const int inf = 1e9; int n, ans[N * N]; vector<pair<int,int>> query[N]; vector<int> Do(vector<int> x) { vector<int> l, r; for(int i = 1; i <= n / 2; i++) l.push_back(x[i]); for(int i = n / 2 + 1; i <= n; i++) r.push_back(x[i]); vector<int> ans(1); int tl = 0, tr = 0; while(tl < (int)l.size() && tr < (int)r.size()) { if(l[tl] < r[tr]) ans.push_back(l[tl++]); else ans.push_back(r[tr++]); } while(tl < (int)l.size()) ans.push_back(l[tl++]); while(tr < (int)r.size()) ans.push_back(r[tr++]); return ans; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int q; cin >> n >> q; vector<int> a(n + 1); for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= q; i++) { int t, pos; cin >> t >> pos; query[min(t, n)].push_back({pos, i}); } for(int i = 0; i <= n; i++) { for(auto x : query[i]) { ans[x.second] = a[x.first]; } a = Do(a); } for(int i = 1; i <= q; i++) cout << ans[i] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...