Submission #478167

#TimeUsernameProblemLanguageResultExecution timeMemory
478167FatihSolakNizovi (COI14_nizovi)C++17
100 / 100
222 ms220 KiB
#include <bits/stdc++.h> using namespace std; int ask(int x,int y){ cout << "cmp " << x << " " << y << endl; int ret; cin >> ret; return ret; } void rev(int l,int r){ if(l >= r)return; cout << "reverse " << l << " " << r << endl; } int main(){ int a,b; cin >> a >> b; int pos = 1; int cntb = b; for(int i=1;i<=a && cntb;i++){ int l = pos + a - i + 1, r = a+b; int cnt = -l; if(ask(pos,l) != 1){ pos++; continue; } while(l < r){ int m = (l + r + 1)/2; if(ask(m,pos) != -1){ r = m-1; } else l = m; } cnt += l; cntb -= cnt + 1; rev(pos,l); rev(pos,pos+cnt); rev(pos+cnt+1,l); pos += cnt + 2; } cout << "end" << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...