Submission #745581

#TimeUsernameProblemLanguageResultExecution timeMemory
745581lukadupliNizovi (COI14_nizovi)C++14
60 / 100
87 ms292 KiB
#include <bits/stdc++.h> using namespace std; bool cmp(int a, int b){ cout << "cmp " << a << ' ' << b << endl; int x; cin >> x; return x == -1; } void rev(int l, int r){ if(l == r) return; cout << "reverse " << l << ' ' << r << endl; } int A, B; int main() { cin >> A >> B; rev(1, A); int pos = A; if(cmp(A + 1, A)) pos = A + 1; while(pos > 1){ int l = 1, r = pos; while(r > l){ int m = (l + r) / 2; if(cmp(m, pos + 1)) r = m; else l = m + 1; } rev(l, pos); pos = l; if(pos == 1) break; l = pos; r = A + B; while(r > l){ int m = (l + r + 1) / 2; if(cmp(m, pos - 1)) l = m; else r = m - 1; } rev(pos, r); rev(pos - 1, r); pos--; } cout << "end" << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...