#include using namespace std; int unimodalFunc(int mid) { cout << mid << " " << 0 << endl; int Q; cin >> Q; return (Q); } int unimodalFunc2(int mid) { cout << 0 << " " << mid << endl; int Q; cin >> Q; return (Q); } int findMaximal(int from, int to) { for(; to - from > 1;) { int mid = (from + to) / 2; (unimodalFunc(mid) - unimodalFunc(mid - 1) < 0 ? from : to) = mid; } return from; } int findMaximal2(int from, int to) { for(; to - from > 1;) { int mid = (from + to) / 2; (unimodalFunc2(mid) - unimodalFunc2(mid - 1) > 0 ? from : to) = mid; } return from; } int main() { int get = findMaximal(0, 100001); int get2 = findMaximal2(0, 100001); cout << get << " " << get2 << endl; }