Submission #597181

# Submission time Handle Problem Language Result Execution time Memory
597181 2022-07-15T16:41:30 Z flappybird Colors (BOI20_colors) C++17
0 / 100
1 ms 208 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 201010
#define MAXS 20
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
int query(ll x) {
	cout << "? " << x << endl;
	int a;
	cin >> a;
	return a;
}
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	ll N;
	cin >> N;
	ll l, r;
	l = 1, r = N;
	vector<ll> big;
	ll dir = 1;
	while (1) {
		ll mid = (l + r) / 2;
		l = mid + 1;
		big.push_back(mid);
		if (mid == r - 1) break;
	}
	reverse(big.begin(), big.end());
	ll st = 1;
	for (auto v : big) st += v * dir, dir *= -1;
	l = 1;
	r = N;
	query(st);
	int str = 1;
	while (l < r) {
		ll mid = (l + r) / 2;
		int res = query(st + dir * mid);
		st += dir * mid;
		dir *= -1;
		if (res) {
			r = mid;
			if (str) {
				query(N - r);
				str = 0;
				dir = 1;
				st = N - r;
			}
		}
		else l = mid + 1;
	}
	cout << "= " << r << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Hair color 3 was used multiple times
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Hair color 3 was used multiple times
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Hair color 3 was used multiple times
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Hair color 3 was used multiple times
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Hair color 3 was used multiple times
2 Halted 0 ms 0 KB -