답안 #1036793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036793 2024-07-27T17:16:04 Z MarwenElarbi Colors (BOI20_colors) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define int long long
using namespace std;
int query(int x){
    cout <<"? "<<x<<endl;
    int ans;
    cin>>ans;
    return ans;
}
signed main(){
    //setIO("closing");
    int n;
    cin>>n;
    int l=0;
    int r=n;
    int pos=1;
    vector<int> tab;
    while(r-l>1){
        tab.pb((r+l)/2);
        l=(r+l)/2;
    }
    for(auto u:tab)
        pos+=(pos+u <= n ? u : -u);
    map<int,bool> vis;
    l=0;r=n;
    vis[pos]=true;
    query(pos);
    while(r-l>1){
        int mid=(r+l)/2;
        if(pos+mid<=n&&!vis[pos+mid]){
            pos+=mid;
        }else pos-=mid;
        vis[pos]=1;
        if(query(pos)) r=mid;
        else l=mid;
    }
    cout <<"= "<<r<<endl;
}   
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB OK (4 queries)
2 Runtime error 0 ms 344 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB OK (4 queries)
2 Runtime error 0 ms 344 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB OK (4 queries)
2 Runtime error 0 ms 344 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB OK (4 queries)
2 Runtime error 0 ms 344 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB OK (4 queries)
2 Runtime error 0 ms 344 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -