Submission #667146

# Submission time Handle Problem Language Result Execution time Memory
667146 2022-11-30T12:59:45 Z Darren0724 Colors (BOI20_colors) C++17
0 / 100
0 ms 208 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    int l=1,r=n;
    vector<int> v;
    while(r-l>1){
        int m=(l+r)>>1;
        v.push_back(m);
        l=m;
    }
    bool flag=0;
    int s=n;
    int n1=v.size();
    for(int i=n1-1;i>=0;i--){
        if(flag==0){
            s-=v[i];
        }
        else{
            s+=v[i];
        }
        flag^=1;
    }
    cout<<"? "<<s<<endl;

    int b=0;
    cin>>b;
    l=0,r=n;
    while(r-l>1){
        int m=(l+r)>>1;
        if(flag==1){
            s+=m;
        }
        else{
            s-=m;
        }
        flag^=1;
        cout<<"? "<<s<<endl;
        int k;cin>>k;
        if(k==1){
            r=m;
        }
        else{
            l=m;
        }
    }
    cout<<"= "<<r<<endl;


    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -