Submission #772660

#TimeUsernameProblemLanguageResultExecution timeMemory
772660dooweyAbracadabra (CEOI22_abracadabra)C++14
0 / 100
3062 ms39884 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const int N = (int)2e5 + 10; void shuffle(vector<int> &P){ queue<int> A, B; for(int i = 0 ; i < P.size(); i ++ ){ if(i < P.size() / 2) A.push(P[i]); else B.push(P[i]); } vector<int> nex; while(!A.empty() || !B.empty()){ if(A.empty()){ nex.push_back(B.front()); B.pop(); } else if(B.empty()){ nex.push_back(A.front()); A.pop(); } else { if(A.front() < B.front()){ nex.push_back(A.front()); A.pop(); } else{ nex.push_back(B.front()); B.pop(); } } } swap(P, nex); } vector<pii> qq[N]; // {index, idx} int res[N]; int main(){ fastIO; //freopen("in.txt", "r", stdin); int n, q; cin >> n >> q; vector<int> P(n); for(int i = 0 ; i < n; i ++ ){ cin >> P[i]; } int t, id; for(int iq = 1; iq <= q; iq ++ ){ cin >> t >> id; t=min(t,n); qq[t].push_back(mp(id, iq)); } for(int i = 0 ; i <= n; i ++ ){ if(i) shuffle(P); for(auto x : qq[i]){ res[x.se] = P[x.fi-1]; } } for(int iq = 1; iq <= q; iq ++ ){ cout << res[iq] << "\n"; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void shuffle(std::vector<int>&)':
Main.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i = 0 ; i < P.size(); i ++ ){
      |                     ~~^~~~~~~~~~
Main.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if(i < P.size() / 2) A.push(P[i]);
      |            ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...