제출 #1231963

#제출 시각아이디문제언어결과실행 시간메모리
1231963ender_shayanColors (BOI20_colors)C++17
0 / 100
1 ms412 KiB
#include <bits/stdc++.h>

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

typedef long long ll;
typedef long double	ld;
typedef pair<int, int>	pii  ;
typedef pair<ll, ll>	pll  ;
typedef vector<pii>     vii  ;
typedef vector<int>     veci ;
typedef vector<pll>     vll  ;
typedef vector<ll>      vecll;

// find_by_order             order_of_key

//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define F		        first
#define S		        second
#define pb		        push_back
#define Mp		        make_pair
#define all(x)          x.begin(), x.end()
#define debug(x)        cerr << #x << " = " << x << endl
#define set_dec(x)	    cout << fixed << setprecision(x);
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define lb              lower_bound
#define ub              upper_bound
#define for1(n)         for(int i=1;i<=n;i++)
#define for0(n)         for(int i=0;i<n;i++)
#define forn(n)         for(int i=n;i>0;i--)
#define pq              priority_queue <pii, vector<pii>, greater<pii>>


int n,L,vis[1000];

bool ask(ll t){
    if(t<=0 || t>n)exit(0);
    cout<<"? "<<t<<endl;
    bool o;cin>>o;
    o^=1;
    return o;
}
int main(){
    cin>>n;
    ll s=n,tmp=0;L=log2(n-1);
    vector<ll>vec;
    ll t=0;
    while(t!=n-1){
        t=(t+n)/2;
        vec.pb(t);
    }
    reverse(all(vec));
    for(ll x:vec){
        if(s-x>0)
            s-=x;
        else
            s+=x;
    }
    ask(s);
    ll l=0,r=n;
    while(r-l!=1){
        ll mid=(l+r)>>1;
        ll ss=s;
        if(ss<=n/2)ss+=mid;
        else ss-=mid;
        if(ask(ss))l=mid;
        else r=mid;
        s=ss;
    }
    cout<<"= "<<l+1<<endl;



}



#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...