Submission #528079

# Submission time Handle Problem Language Result Execution time Memory
528079 2022-02-19T07:09:03 Z SiddhantAttavar Colors (BOI20_colors) C++14
0 / 100
300 ms 288 KB
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline void input(T& inVar) {cin >> inVar;}
template<typename T, typename... S> inline void input(T& inVar, S&... args) {cin >> inVar; input(args ...);}
template<typename T> inline void print(T outVar) {cout << outVar << endl;}
template<typename T, typename... S> inline void print(T outVar, S... args) {cout << outVar << ' '; print(args ...);}
#define range(it, start, end) for (int it = start; it < end; it++)
#define arrPut(var) for (auto &inVar : var) {cin >> inVar;}
#define arrPrint(var) for (auto outVar : var) {cout << outVar << ' ';} cout << endl
#define setup() ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long

int32_t main() {
	// setup();
	
	int n;
	input(n);
	
	int l = 1, r = n, c = 0;
	bool flag = false;
	while (l + 1 < r) {
		int m = (l + r) / 2;
		if (flag) {
			c -= m;
		}
		else {
			c += m;
		}
		l = m;
		flag = !flag;
	}

	if (c < 0) {
		c = -c;
	}

	l = 1;
	r = n;
	int res = n;
	print("? ", c);
	bool f;
	input(f);
	set<int> done;
	while (l <= r) {
		int m = (l + r) / 2;
		if (c + m <= n and !done.count(c + m)) {
			c += m;
		}
		else if (c - m >= 1 and !done.count(c - m)) {
			c -= m;
		}
		else {
			range(i, 1, n + 1) {
				if (!done.count(i)) {
					c = i;
					print("? ", c);
					bool b;
					input(b);
					done.insert(i);
					c = i;
					break;
				}
			}
			continue;
		}

		print("? ", c);
		done.insert(c);

		bool b;
		input(b);
		if (b) {
			res = m;
			r = m - 1;
		}
		else {
			l = m + 1;
		}
	}
	print("= ", res);
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB OK (4 queries)
2 Correct 1 ms 200 KB OK (9 queries)
3 Correct 1 ms 288 KB OK (4 queries)
4 Correct 1 ms 200 KB OK (5 queries)
5 Correct 0 ms 200 KB OK (6 queries)
6 Correct 1 ms 200 KB OK (7 queries)
7 Correct 1 ms 200 KB OK (7 queries)
8 Correct 1 ms 200 KB OK (7 queries)
9 Correct 1 ms 200 KB OK (6 queries)
10 Correct 1 ms 284 KB OK (4 queries)
11 Execution timed out 3036 ms 200 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB OK (4 queries)
2 Correct 1 ms 200 KB OK (9 queries)
3 Correct 1 ms 288 KB OK (4 queries)
4 Correct 1 ms 200 KB OK (5 queries)
5 Correct 0 ms 200 KB OK (6 queries)
6 Correct 1 ms 200 KB OK (7 queries)
7 Correct 1 ms 200 KB OK (7 queries)
8 Correct 1 ms 200 KB OK (7 queries)
9 Correct 1 ms 200 KB OK (6 queries)
10 Correct 1 ms 284 KB OK (4 queries)
11 Execution timed out 3036 ms 200 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB OK (4 queries)
2 Correct 1 ms 200 KB OK (9 queries)
3 Correct 1 ms 288 KB OK (4 queries)
4 Correct 1 ms 200 KB OK (5 queries)
5 Correct 0 ms 200 KB OK (6 queries)
6 Correct 1 ms 200 KB OK (7 queries)
7 Correct 1 ms 200 KB OK (7 queries)
8 Correct 1 ms 200 KB OK (7 queries)
9 Correct 1 ms 200 KB OK (6 queries)
10 Correct 1 ms 284 KB OK (4 queries)
11 Execution timed out 3036 ms 200 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB OK (4 queries)
2 Correct 1 ms 200 KB OK (9 queries)
3 Correct 1 ms 288 KB OK (4 queries)
4 Correct 1 ms 200 KB OK (5 queries)
5 Correct 0 ms 200 KB OK (6 queries)
6 Correct 1 ms 200 KB OK (7 queries)
7 Correct 1 ms 200 KB OK (7 queries)
8 Correct 1 ms 200 KB OK (7 queries)
9 Correct 1 ms 200 KB OK (6 queries)
10 Correct 1 ms 284 KB OK (4 queries)
11 Execution timed out 3036 ms 200 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB OK (4 queries)
2 Correct 1 ms 200 KB OK (9 queries)
3 Correct 1 ms 288 KB OK (4 queries)
4 Correct 1 ms 200 KB OK (5 queries)
5 Correct 0 ms 200 KB OK (6 queries)
6 Correct 1 ms 200 KB OK (7 queries)
7 Correct 1 ms 200 KB OK (7 queries)
8 Correct 1 ms 200 KB OK (7 queries)
9 Correct 1 ms 200 KB OK (6 queries)
10 Correct 1 ms 284 KB OK (4 queries)
11 Execution timed out 3036 ms 200 KB Time limit exceeded
12 Halted 0 ms 0 KB -