Submission #1179119

#TimeUsernameProblemLanguageResultExecution timeMemory
1179119acoatoitgsAbracadabra (CEOI22_abracadabra)C++17
10 / 100
932 ms589824 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #define ll long long #define all(a) (a).begin(), (a).end() #define LL_INF 0x3f3f3f3f3f3f3f3f #define INF 0x3f3f3f3f void solve(); int main() { ll N, Q; cin >> N >> Q; vector<vector<ll>> V(1, vector<ll>(N)); for(auto &i : V[0]) cin >> i; ll half = N/2; bool eq = 0; auto sim = [&]() -> vector<ll> { eq = 1; ll i = 0, j = half; ll ij = 0; vector<ll> ans(N); while(i != half && j != N) { if(V.back()[i] < V.back()[j]) ans[ij++] = V.back()[i++]; else ans[ij++] = V.back()[j++]; } while(i != half) ans[ij++] = V.back()[i++]; while(j != N) ans[ij++] = V.back()[j++]; for(int i = 0; i < N; i++) if(ans[i] != V.back()[i]) { eq = 0; break; } return ans; }; auto pr = [&](vector<ll> &V) -> void { for(int i = 0; i < half; i++) cout << V[i] << " "; cout << " # "; for(int i = half; i < N; i++) cout << V[i] << " "; cout << "\n"; }; // pr(V[0]); while(!eq) { V.push_back(sim()); // pr(V.back()); } while(Q--) { ll x,y; cin >> x >> y, --y; x = min(x, (ll)(V.size()-1)); cout << V[x][y] << "\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...