Submission #745587

#TimeUsernameProblemLanguageResultExecution timeMemory
745587lukadupliNizovi (COI14_nizovi)C++14
0 / 100
28 ms276 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 pos, int fall){ //cout << "solving: " << pos << ' ' << fall << '\n'; if(pos >= A + B || fall > A + B || pos >= fall) return; if(cmp(pos, fall)){ int l = pos + 1, r = fall - 1; while(r > l){ int m = (l + r) / 2; if(!cmp(m, fall)) r = m; else l = m + 1; } if(l == fall - 1 && cmp(l, fall)) return; pos = l; } //cout << "adjusted to: " << pos << ' ' << fall << '\n'; if(pos >= A + B || fall > A + B || pos >= fall) return; int l = fall, r = A + B; while(r > l){ int m = (l + r + 1) / 2; if(cmp(m, pos)) l = m; else r = m - 1; } rev(pos, l); rev(pos, pos + l - fall); rev(pos + l - fall + 1, fall); solve(pos + l - fall + 1, l + 1); } int main() { cin >> A >> B; solve(1, A + 1); cout << "end" << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...