Submission #649824

#TimeUsernameProblemLanguageResultExecution timeMemory
649824DJeniUpColors (BOI20_colors)C++17
0 / 100
1 ms208 KiB
#include "bits/stdc++.h" //#pragma GCC optimize("O3") using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll>pairll; typedef long double ld; #define fr first #define sc second #define pb push_back #define INF 100000000007 #define endl '\n' #define MOD 998244353 #define A 31 #define N 500007 ll n; int main(){ cin>>n; ll x=0; ll a=n/2+1; ll b=a; ll y=0; ll l=1; ll r=n; for(int i=pow(2,20);i>=8;i/=2){ if(x+i<n-2){ a=max(1ll,(n-x-i)/2); b=a+x+i; cout<<"? "<<a<<endl; cout.flush(); cin>>y; cout<<"? "<<b<<endl; cout.flush(); cin>>y; if(y==0)x+=i; else{ l=a+1; r=b-1; } } } if(n<=7){ cout<<"? "<<b<<endl; cout.flush(); cin>>y; } ll f=1; while(a>l && b<r){ if(f==1){ f=0; a--; cout<<"? "<<a<<endl; cout.flush(); cin>>y; if(y==0)x++; }else{ f=1; b++; cout<<"? "<<b<<endl; cout.flush(); cin>>y; if(y==0)x++; } } cout<<"= "<<x+1<<endl; cout.flush(); return 0; }
#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...