Submission #1123969

#TimeUsernameProblemLanguageResultExecution timeMemory
1123969EfeBabagilAbracadabra (CEOI22_abracadabra)C++20
10 / 100
3094 ms19952 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<int> suf(vector<int> v) { vector<int> ans; int m = n/2; int i = 0, j = m; while ((i < m) || (j < n)) { if (i == m) { ans.push_back(v[j]); j++; continue; } if (j == n) { ans.push_back(v[i]); i++; continue; } if (v[i] < v[j]) { ans.push_back(v[i]); i++; } else { ans.push_back(v[j]); j++; } } return ans; } int32_t main() { int q; cin >> n >> q; vector<int> arr(n); for (int i=0; i<n;i++) cin >> arr[i]; vector<pair<pair<int,int>, int>> queries(q); vector<int> ans(q); for (int i=0; i<q;i++) { cin >> queries[i].first.first >> queries[i].first.second; queries[i].second = i; } sort(queries.begin(), queries.end()); int t = 0; int flag = 0; for (int i=0;i<q;i++) { while ((queries[i].first.first > t) && !flag) { vector<int> temp = suf(arr); if (temp == arr) { flag = 1; } else { arr = temp; } t++; } ans[queries[i].second] = arr[queries[i].first.second - 1]; } for (int i=0;i<q;i++) cout << ans[i] <<endl; /* vector<int> srt={7,5,2,9,10,8,4,3,6,1}; for(int i=0;i<10;i++) { srt=suf(srt); for(int i=0;i<10;i++) { cout<<srt[i]<<" "; } cout<<endl; } */ }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...