제출 #858760

#제출 시각아이디문제언어결과실행 시간메모리
858760maks007Colors (BOI20_colors)C++14
0 / 100
0 ms440 KiB
#include "bits/stdc++.h"

using namespace std;

signed main () {
	int n;
	cin >> n;
	map <int,pair <int,int>> mp;
	set <int> s;
	for(int i = 1; i <= n; i ++) s.insert(i);
	int need = n;
	for(int i = 1; i < need; i ++, need --) {
		mp[need-i] = {i, need};
	}
	need = n - 1;
	for(int i = 1; i < need; i ++, need --) {
		mp[need-i] = {i, need};
	}
	int l = 1, r = n-1, cnt = 0;
	pair <int,int> prev = {-1,-1};
	while(l < r) {
		int mid = (l + r) / 2;
		cout << l << " " << r << " " << mid << "\n";
		int x;
		if(prev.second == mp[mid].first) {
			cnt ++;
			cout << "? " << mp[mid].second << endl;
			s.erase(mp[mid].second);
			prev = {mp[mid].first, mp[mid].second};
			cin >> x;
		} else if (prev.second == mp[mid].second) {
			cnt ++;
			cout << "? " << mp[mid].first << endl;
			s.erase(mp[mid].first);
			prev = {mp[mid].second, mp[mid].first};
			cin >> x;
		}else {	
			cnt += 2;
			cout << "? " << mp[mid].first << endl;
			cin >> x;
			cout << "? " << mp[mid].second << endl;
			s.erase(mp[mid].first);
			s.erase(mp[mid].second);
			prev = {mp[mid].first, mp[mid].second};
			cin >> x;
		}
		if(x == 1) r = mid;
		else l = mid + 1;
	}
	assert(cnt <= 64);
	cout << "= " << r;
	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...