Submission #745583

#TimeUsernameProblemLanguageResultExecution timeMemory
745583lukadupliNizovi (COI14_nizovi)C++14
40 / 100
49 ms288 KiB
#include <bits/stdc++.h> #define f first #define s second using namespace std; typedef pair<int, int> pii; 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; void solve(int l, int r){ if(l == 1) return; if(l < r){ int lo = 1, hi = l - 1; if(r < A + B){ while(hi > lo){ int mi = (lo + hi) / 2; if(cmp(mi, r + 1)) hi = mi; else lo = mi + 1; } } rev(l, r); solve(r, lo); } else{ int lo = l + 1, hi = A + B; if(r > 1){ while(hi > lo){ int mi = (lo + hi + 1) / 2; if(cmp(mi, r - 1)) lo = mi; else hi = mi - 1; } } rev(r, l); solve(r, lo); } } int main() { cin >> A >> B; rev(1, A); int pos = A; if(cmp(A + 1, A)) pos = A + 1; if(pos == A + B) rev(1, 2); else solve(pos, pos + 1); cout << "end" << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...