제출 #1036779

#제출 시각아이디문제언어결과실행 시간메모리
1036779vjudge1Abracadabra (CEOI22_abracadabra)C++17
0 / 100
3065 ms44960 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define x first #define y second ll dx[]={1, 1, 0,-1,-1, -1, 0, 1}; ll dy[]={0, 1, 1, 1, 0, -1,-1,-1}; int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); ll n,t; cin>>n>>t; vector<ll> cad(n); for(int i=0; i<n; i++) cin>>cad[i]; vector<ll> fin=cad; sort(fin.begin(),fin.end()); priority_queue<pair<ll,ll>> q; vector<ll> query(t,0); for(int i=0; i<t; i++) { ll a,b; cin>>a>>b; query[i]=b; q.push({-a,i}); } ll cnt=0; while(fin!=cad) { while(!q.empty()&&-cnt==q.top().first) { query[q.top().second]=cad[query[q.top().second]-1]; q.pop(); } if(q.empty()) break; fin=cad; vector<ll> temp; ll i=0; ll d=n/2; while(i!=n/2||d!=n) { if(i==n/2) { while(d<n) { temp.push_back(cad[d]); d++; } } else if(d==n) { while(i<n/2) { temp.push_back(cad[i]); i++; } } else if(cad[i]<cad[d]) temp.push_back(cad[i++]); else temp.push_back(cad[d++]); } cad=temp; cnt++; } if(!q.empty()) { query[q.top().second]=cad[query[q.top().second]-1]; q.pop(); } for(auto i:query) cout<<i<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...