Submission #1019936

#TimeUsernameProblemLanguageResultExecution timeMemory
1019936AbitoAbracadabra (CEOI22_abracadabra)C++17
0 / 100
355 ms181416 KiB
#include <bits/stdc++.h> #define F first #define S second #define pb push_back #define ppb pop_back #define ep insert #define endl '\n' #define elif else if #define pow pwr #define sqrt sqrtt #define int long long #define ll long long typedef unsigned long long ull; using namespace std; int n,q; vector<vector<int>> v; int32_t main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>n>>q; v.pb({}); v[0].resize(n); for (int i=0;i<n;i++) cin>>v[0][i]; for (int k=1;k<=100;k++){ vector<int> b; int i=0,j=n/2; while (i<n/2 && j<n){ if (v.back()[i]<v.back()[j]) b.pb(v.back()[i++]); else b.pb(v.back()[j++]); } while (i<n/2) b.pb(v.back()[i++]); while (j<n) b.pb(v.back()[j++]); v.pb(b); bool ok=true; for (int i=0;i<n/2;i++) ok&=(b[i]==i+1); if (ok) break; } while (q--){ int t,i; cin>>t>>i; t=min(t,(int)v.size()-1); cout<<v[t][i-1]<<endl; } 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...