Submission #478079

#TimeUsernameProblemLanguageResultExecution timeMemory
478079FatihSolakNizovi (COI14_nizovi)C++17
90 / 100
208 ms288 KiB
#include <bits/stdc++.h> #define N 200005 using namespace std; vector<int> v = {-1,3,2,4,5}; int ask(int x,int y){ /* if(v[x-1] < v[y-1]){ return -1; } if(v[x - 1] > v[y - 1]){ return 1; } if(v[x - 1] == v[y - 1]){ return 0; }*/ cout << "cmp " << x << " " << y << endl; int ret; cin >> ret; return ret; } void reverse(int l,int r){ //reverse(v.begin() + l - 1,v.begin() + r); cout << "reverse " << l << " " << r << endl; } void solve(){ int a,b; cin >> a >> b; int pos = 1; for(int i=1;i<=a && pos < a + b;i++){ int l = pos + a - i + 1, r = a+b; int cnt = -l; if(ask(pos,l) != 1){ pos++; continue; } //cout << i << endl; while(l < r){ int m = (l + r + 1)/2; if(ask(m,pos) == 1){ r = m-1; } else l = m; } //cout << l << endl; cnt += l; reverse(pos,l); reverse(pos,pos+cnt); reverse(pos+cnt+1,l); pos += cnt + 2; } cout << "end" << endl; } int32_t main(){ int t=1; //cin>>t; while(t--){ solve(); } #ifdef Local cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...