# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
470550 | cp_is_hard | Colors (BOI20_colors) | C++14 | 1 ms | 200 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b)
using namespace std;
#define INF 1000000000000000000
#define lld long double
#define int long long int
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#ifdef wiwihorz
#define print(a...) kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else
#define print(...)
#define vprint(...)
#endif
namespace solver {
set<int> s;
const int key = 71;
int cur = -1, cnt;
bool query(int p) {
cout << "? " << p << endl;
int x; cin >> x;
// x = (cur == -1 ? 0 : abs(p - cur) >= key);
// cur = p;
// cnt ++;
return x;
}
void ans(int x) {
cout << "= " << x << endl;
}
void solve(int n) {
cnt = 0;
int dn = n + !(n & 1);
int v = (1 + n) / 2;
int L = 0, R = ((n & 1) ? v : v - 1);
while(R - L > 1) {
int mid = (L + R) / 2;
s.insert(v - mid);
s.insert(v + mid);
query(v - mid);
bool ans = query(v + mid);
if(ans) R = mid;
else L = mid;
}
// ans is 2 * L + 1 or 2 * L + 2;
if(2 * L + 2 > n) ans(2 * L + 1);
else {
int ll = 1;
while(s.find(ll) != s.end() ||
s.find(ll + 2 * L + 1) != s.end()) ll++;
query(ll);
if(query(ll + 2 * L + 1)) ans(2 * L + 1);
else ans(2 * L + 2);
}
}
};
using namespace solver;
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int n; cin >> n;
solve(n);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |