Submission #1280778

#TimeUsernameProblemLanguageResultExecution timeMemory
1280778mdobricColors (BOI20_colors)C++20
0 / 100
1 ms428 KiB
#include <bits/stdc++.h>
using namespace std;

long long n;
int ans;

int main (void){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	long long mini = 0;
	long long maxi = (n - 1) / 32;
	long long pola = (mini + maxi + 1) / 2;
	int prosli = -1;
	if (maxi % 2 == 0){
		cout << "? " <<  pola * 32 + 1 << endl;
		cin >> ans;
		for (int i = 1; i <= maxi - pola; i++){
			cout << "? " << (pola + i) * 32 + 1 << endl;
			cin >> ans;
			if (ans == 1 and prosli == -1) prosli = 2 * i - 1;
			cout << "? " << (pola - i) * 32 + 1 << endl;
			cin >> ans;
			if (ans == 1 and prosli == -1) prosli = 2 * i;
		}
	}
	else{
		for (int i = 0; i <= maxi - pola; i++){
			cout << "? " << (pola + i) * 32 + 1 << endl;
			cin >> ans;
			if (i != 0 and ans == 1 and prosli == -1) prosli = 2 * i + 1;
			cout << "? " << (pola - i - 1) * 32 + 1 << endl;
			cin >> ans;
			if (ans == 1 and prosli == -1) prosli = 2 * i + 2;
		}
	}
	
	long long rez, tr, zadnji, granica;	
	if (prosli == -1){
		rez = n;
		tr = n - 1;
		zadnji = 1;
		granica = maxi * 32;
	}
	else{
		rez = prosli * 32;
		tr = prosli * 32 - 1;
		zadnji = 1;
		granica = prosli * 32 - 32;
	}
		while (tr > granica){
			cout << "? " << zadnji + tr << endl;
			cin >> ans;
			if (ans == 1) rez--;
			zadnji += tr;
			tr--;
			if (tr == granica) break;
			cout << "? " << zadnji - tr << endl;
			cin >> ans;
			if (ans == 1) rez--;
			zadnji -= tr;
			tr--;
		}
		cout << "= " << rez << endl;

	
	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...