| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1299158 | flo | Colors (BOI20_colors) | C++20 | 1 ms | 408 KiB |
#include <bits/stdc++.h>
#define task "testing"
#define ll long long
#define multitest 0
using namespace std;
bool ask(ll x) {
cout << "? " << x << "\n";
bool c; cin >> c;
return c;
}
void guess(ll x) {
cout << "= " << x << "\n";
}
void flo(int ID) {
ll n; cin >> n;
int sign = -1;
ll l = 1, r = n-1, st = n;
while (l <= r) {
ll mid = (l+r)/2;
st += sign*mid;
sign *= -1, l = mid+1;
}
l = 1, r = n-1, sign = 1;
ll ans = -1;
ask(st);
while (l <= r) {
ll mid = (l+r)/2;
st += sign*mid, sign *= -1;
bool c = ask(st);
if (c == 1) {
r = (ans = mid)-1;
}
else {
l = mid+1;
}
}
guess(ans);
}
int main() {
// ios_base::sync_with_stdio(0);
// cin.tie(0); cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int TCS = 1, ID = 1;
if (multitest) {
cin >> TCS;
}
while (TCS--) flo(ID++);
return 0;
}
Compilation message (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... | ||||
