Submission #827695

# Submission time Handle Problem Language Result Execution time Memory
827695 2023-08-16T16:29:39 Z QwertyPi Colors (BOI20_colors) C++14
0 / 100
0 ms 208 KB
#include <bits/stdc++.h>


using namespace std;

#ifndef LOCAL
bool qry(int x){
	cout << "? " << x << endl;
	bool r; cin >> r;
	return r;
}
void answer(int x){
	cout << "= " << x << endl;
	exit(0);
}
#else
int prv = -1, N, C;
bool qry(int x){
	assert(1 <= x && x <= N);
	if(prv == -1) { prv = x; return 0; } 
	bool res = abs(x - prv) >= C; prv = x;
	return res;
}
void answer(int x){
	assert(x == C);
}
#endif

void solve(int N){
	int lo = 1, hi = N;
	while(lo != hi){
		int mid = (lo + hi) / 2;
		qry(1);
		if(qry(mid + 1)){
			hi = mid;
		}else{
			lo = mid + 1;
		}
	}
	cout << lo << endl;
	answer(lo);
}

int32_t main(){
#ifdef LOCAL
	random_device rd;
	mt19937 rng(rd());

	const int MX = 10;
	for(int t = 0; t < 1000; t++){
		N = rng() % MX + 1;
		C = rng() % N + 1;
		solve(N);
	}
#else
	int N; cin >> N;
	solve(N);
#endif
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -