Submission #65100

#TimeUsernameProblemLanguageResultExecution timeMemory
65100bazsi700Cake (CEOI14_cake)C++14
0 / 100
372 ms96784 KiB
#include <bits/stdc++.h> using namespace std; struct Block { bool L; int prevblocksizesl; int prevblocksizesr; int siz; vector<pair<int,int> > tops; }; int arr[250005]; vector<int> smallranks; //14:45-19:45 int main() { ios::sync_with_stdio(false); cin.tie(0); int n,A; cin >> n >> A; vector<pair<int,int> > tosort (n); for(int i = 1; i <= n; i++) { cin >> arr[i]; tosort[i-1] = {arr[i],i}; } sort(tosort.begin(),tosort.end()); for(int i = 0; i <= 10; i++) { smallranks.push_back(tosort[i].second); } int Q; cin >> Q; vector<pair<int,int> > quer(Q); int fcn = 0; int ecn = 0; for(int i = 0; i < Q; i++) { char ch; cin >> ch; if(ch == 'F') { int pos; cin >> pos; quer[i] = {pos,-1}; fcn++; } else { int pos,ran; cin >> pos >> ran; quer[i] = {pos,ran}; ecn++; } } if((n <= 10000 && Q <= 10000) || fcn <= 500) { for(auto q : quer) { if(q.second == -1) { int pos = q.first; int leftind = A-1; int rightind = A+1; for(int i = 1; i < n; i++) { if(leftind == 0) { if(rightind == pos) { cout << i << "\n"; break; } rightind++; continue; } if(rightind == n+1) { if(leftind == pos) { cout << i << "\n"; break; } leftind--; continue; } if(arr[leftind] < arr[rightind]) { if(leftind == pos) { cout << i << "\n"; break; } leftind--; continue; } else { if(rightind == pos) { cout << i << "\n"; break; } rightind++; continue; } } } else { int pos = q.first; int ran = q.second; bool cont = false; for(int el : smallranks) { if(el == pos) { cont = true; } } if(!cont) { vector<int> nwv; for(int i = 0; i < ran-1; i++) { nwv.push_back(smallranks[i]); } nwv.push_back(pos); for(int i = ran; i < 10; i++) { nwv.push_back(smallranks[i]); } swap(nwv,smallranks); } else { vector<int> nwv; for(int i = 0; i < ran-1; i++) { nwv.push_back(smallranks[i]); } nwv.push_back(pos); for(int i = ran; i <= 10; i++) { if(smallranks[i] != pos) { nwv.push_back(smallranks[i]); } } swap(nwv,smallranks); } int prv = -1; for(int i = 0; i <= 10; i++) { int el = smallranks[i]; if(el == pos) { arr[el] = arr[smallranks[i+1]]+1; break; } arr[el]++; } } } } return 0; }

Compilation message (stderr)

cake.cpp: In function 'int main()':
cake.cpp:124:21: warning: unused variable 'prv' [-Wunused-variable]
                 int prv = -1;
                     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...