# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
357716 | mjhmjh1104 | Colors (BOI20_colors) | C++14 | 1 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
vector<long long> v;
long long n;
int t;
int main() {
scanf("%lld", &n);
long long curr = 1;
long long l = n / 2, r = n - 1;
while (l < r) {
v.push_back(l);
l = (l + r) / 2 + 1;
}
v.push_back(l);
reverse(v.begin(), v.end());
for (auto &i: v) {
if (curr + i <= n) curr += i;
else curr -= i;
}
printf("? %lld\n", curr);
fflush(stdout);
scanf("%*d");
l = 0, r = n - 1;
while (l < r) {
long long m = (l + r) / 2;
if (curr + m <= n) curr += m;
else curr -= m;
printf("? %lld\n", curr);
fflush(stdout);
scanf("%d", &t);
if (t) r = m;
else l = m + 1;
}
if (l == n - 1) {
printf("? %lld\n", n);
fflush(stdout);
scanf("%d", &t);
if (t) printf("= %lld\n", n - 1);
else printf("= %lld\n", n);
} else printf("= %lld\n", l);
fflush(stdout);
}
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... |