Submission #484708

# Submission time Handle Problem Language Result Execution time Memory
484708 2021-11-05T08:01:26 Z ac2hu Colors (BOI20_colors) C++14
0 / 100
1 ms 328 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
map<ll,bool> used;
ll n;
bool good(ll mid, ll &cur){
	if(cur + mid <= n && !used[cur + mid]){
		cur += mid;
		used[cur] = true;
		cout << "? " << cur << endl;
		bool a;cin >> a;
		return a;
	}
	else if(cur - mid > 0 && !used[cur - mid]){
		cur -= mid;
		used[cur] = true;
		cout << "? " << cur << endl;
		bool a;cin >> a;
		return a;
	}
	else{
		vector<int> arr;
		cout << arr[-1] << "\n";
	}
	return false;
}
signed main(){
	cin >> n;
	ll cur = 0;
	good(1,cur);
	ll l = 1,r = n;
	while(l < r){
		ll mid = (l + r)/2;
		if(good(mid,cur)){
			r = mid;
		}
		else{
			l = mid + 1;
		}
	}
	cout << "= "<< l << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB OK (4 queries)
2 Runtime error 1 ms 328 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB OK (4 queries)
2 Runtime error 1 ms 328 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB OK (4 queries)
2 Runtime error 1 ms 328 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB OK (4 queries)
2 Runtime error 1 ms 328 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB OK (4 queries)
2 Runtime error 1 ms 328 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -