Submission #1299158

#TimeUsernameProblemLanguageResultExecution timeMemory
1299158floColors (BOI20_colors)C++20
0 / 100
1 ms408 KiB
#include <bits/stdc++.h>
#define task "testing"
#define ll long long
#define multitest 0
using namespace std;

bool ask(ll x) {
	cout << "? " << x << "\n";
	
	bool c; cin >> c;
	
	return c;
}

void guess(ll x) {
	cout << "= " << x << "\n";
}

void flo(int ID) {
	ll n; cin >> n;
	
	int sign = -1;
	
	ll l = 1, r = n-1, st = n;
	
	while (l <= r) {
		ll mid = (l+r)/2;
		
		st += sign*mid;
		
		sign *= -1, l = mid+1;
	}
	
	l = 1, r = n-1, sign = 1;
	
	ll ans = -1;
	
	ask(st);
	
	while (l <= r) {
		ll mid = (l+r)/2;
		
		st += sign*mid, sign *= -1;
		
		bool c = ask(st);
		
		if (c == 1) {
			r = (ans = mid)-1;
		}
		else {
			l = mid+1;
		}
	}
	
	guess(ans);
}

int main() {
	// ios_base::sync_with_stdio(0);
	// cin.tie(0); cout.tie(0);

	if (fopen(task".inp", "r")) {
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
	}

	int TCS = 1, ID = 1;

	if (multitest) {
		cin >> TCS;
	}

	while (TCS--) flo(ID++);

	return 0;
}

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:63:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |                 freopen(task".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Colors.cpp:64:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |                 freopen(task".out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...