답안 #536334

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
536334 2022-03-13T01:31:09 Z skittles1412 Colors (BOI20_colors) C++17
0 / 100
0 ms 208 KB
#include "bits/extc++.h"

using namespace std;

template <typename T>
void dbgh(const T& t) {
	cerr << t << endl;
}

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
	cerr << t << " | ";
	dbgh(u...);
}

#ifdef DEBUG
#define dbg(...)                                           \
	cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \
		 << ": ";                                          \
	dbgh(__VA_ARGS__)
#else
#define cerr   \
	if (false) \
	cerr
#define dbg(...)
#endif

#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())

void solve() {
	int n;
	cin >> n;
	vector<int> vals;
	for (int i = 1; i <= n; i += 32) {
		vals.push_back(i);
	}
	vector<int> ord;
	int l = 0, r = sz(vals);
	while (l < r) {
		ord.push_back(vals[l++]);
		if (l < r) {
			ord.push_back(vals[--r]);
		}
	}
	reverse(begin(ord), end(ord));
	for (auto& a : ord) {
		cout << "? " << a << endl;
	}
	int up = 0;
	for (int i = 0; i < sz(ord) - 1; i++) {
		int x;
		cin >> x;
		if (!x) {
			up = abs(ord[i + 1] - ord[i]);
		}
	}
	int prev = 1;
	bool b = true;
	for (int i = min(n - 1, up + 31); i > up; i--) {
		if (b) {
			prev += i;
		} else {
			prev -= i;
		}
		b ^= true;
		cout << "? " << prev << endl;
		int x;
		cin >> x;
		if (!x) {
			cout << "! " << i + 1 << endl;
			return;
		}
	}
	cout << up << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.exceptions(ios::failbit);
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Token parameter [name=cmd] equals to "!", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Token parameter [name=cmd] equals to "!", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Token parameter [name=cmd] equals to "!", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Token parameter [name=cmd] equals to "!", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Token parameter [name=cmd] equals to "!", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -