Submission #575466

# Submission time Handle Problem Language Result Execution time Memory
575466 2022-06-10T16:30:11 Z _karan_gandhi Colors (BOI20_colors) C++17
0 / 100
1 ms 208 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define all(v) v.begin(), v.end()
#define endl '\n'
#define pl(var) " [" << #var << ": " << (var) << "] "

template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "[" << p.first << ", " << p.second << "]"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) { cout << "["; for(int i = 0; i < (int)v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";}

ll int n;

void solve() {
	cin >> n;

	cout << "? 1" << endl;
	cout.flush();
	int s; cin >> s;

	int hi = n, lo = 2;
	int prev = 1;

	for (int i = 0; i < n - 1; i++) {
		if (i % 2 == 0) {
			cout << "? " << hi-- << endl;
			cout.flush();
			cin >> s;

			if (i == 0 && !s) {
				cout << "=" << n << endl;
				return;
			}

			if (!s) {
				cout << "= " << (abs(prev - (hi + 1))) << endl;
				return;
			}
			prev = hi + 1;
		} else {
			cout << "? " << lo++ << endl;
			cout.flush();
			cin >> s;

			if (!s) {
				cout << "= " << (abs(prev - (lo - 1))) << endl;
				return;
			}
			prev = lo - 1;
		}
	}

	assert(0);
}

int main() {
	// ios::sync_with_stdio(false);
	// cin.tie(nullptr);

	int T = 1;
	// cin >> T;
	while (T--) 
		solve();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Wrong guess
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Wrong guess
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Wrong guess
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Wrong guess
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Wrong guess
2 Halted 0 ms 0 KB -