Submission #1160044

#TimeUsernameProblemLanguageResultExecution timeMemory
1160044LCJLYColors (BOI20_colors)C++20
100 / 100
1 ms436 KiB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
typedef pair<pii,int>pi2;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

//int c=0;
int n=0;

//int lst=0;

set<int>se;

int f(int a){
	cout << "? " << a << endl;
	bool amos;
	cin >> amos;
	return amos;
	
	//test
	//if(se.find(a)!=se.end()){
		//assert(0);
	//}
	
	//se.insert(a);
	
	//bool hold = abs(a-lst) >= c;
	//lst = a;
	//return hold;
}

void solve(){
	cin >> n;
	
	int cur=0;
	int hold=1;
	{
		int l=1;
		int r=n-1;
		int mid;
		bool amos=true;
		while(l<=r){
			mid=(l+r)/2;
			if(amos){
				cur+=mid;
			}
			else cur-=mid;
			
			hold=max(hold,-cur+1);
			
			amos=!amos;
			
			l=mid+1;
		}
	}
	
	//show(hold,hold);
	
	int l=1;
	int r=n-1;
	int mid;
	int best=n;
	bool amos=true;
	
	f(hold);
	
	while(l<=r){
		mid=(l+r)/2;
		if(amos){
			hold+=mid;
		}
		else hold-=mid;
		
		amos=!amos;
		
		if(f(hold)){
			best=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	
	//assert(best==c);
	
	cout << "= " << best << endl;
}
 
int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//freopen("in.txt","r",stdin);
	//freopen("in.txt","w",stdout);
	int t=1;	
	//cin >> t;	
	while(t--){
		solve(); 
	}
}
#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...