Submission #498840

# Submission time Handle Problem Language Result Execution time Memory
498840 2021-12-26T12:44:31 Z akshtsinghania Colors (BOI20_colors) C++14
0 / 100
0 ms 200 KB
#include "bits/stdc++.h"
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long l;
void output(int num){
    cout << "? " << num << endl;
    return;
}
void input(bool &ok){
    int num;
    cin >> num;
    ok = bool(num);
    return;
}
int main()
{
    int n, num; cin >> n;
    int high=n, low=1, llast=INT_MIN;
    cout << "? 0" << endl;
    cin >> num;
    while(low<=high){
        int mid = (high+low+1)>>1;
        output(mid);
        bool ok; input(ok);
        if(high==low&&!ok) {cout << "= " << llast << endl; return 0;}
        else    if(high==low&&ok){cout << "= " << mid << endl; return 0;}
        if(ok)  high = mid-1;
        else    low = mid+1;
        if(ok) llast = mid;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -