# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1101666 |
2024-10-16T14:50:47 Z |
NoMercy |
Colors (BOI20_colors) |
C++17 |
|
1 ms |
336 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ask (ll x) {
cout << "? " << x << endl;
int res;
cin >> res;
return res;
}
int32_t main () {
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
ll N;
cin >> N;
ll ind = 1, dir = 1, cur = 1;
ll lo = 0, hi = N + 1;
while (lo + 1 < hi) {
ll mid = (lo + hi) >> 1;
if (cur + dir * mid >= 1) {
cur += dir * mid;
} else {
ind += 1 - (cur + dir * mid);
cur = 1;
}
lo = mid + 1;
dir = -dir;
}
ask (ind);
lo = 0;
hi = N + 1;
while (lo < hi) {
ll mid = (lo + hi) >> 1;
// cout << lo << " " << mid << " " << hi << " " << ind << "\n";
if (ind - mid >= 1) {
if (ask (ind - mid) == 1) {
hi = mid;
} else {
lo = mid + 1;
}
ind = ind - mid;
} else if (ind + mid <= N) {
if (ask (ind + mid) == 1) {
hi = mid;
} else {
lo = mid + 1;
}
ind = ind + mid;
} else {
if (ind - 1 >= N - ind) {
if (ask(1) == 1) {
hi = ind - 1;
} else {
lo = ind;
}
ind = 1;
} else {
if (ask(N) == 1) {
hi = N - ind;
} else {
lo = N - ind + 1;
}
ind = N;
}
}
}
cout << "= " << hi << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
336 KB |
OK (7 queries) |
3 |
Correct |
1 ms |
336 KB |
OK (4 queries) |
4 |
Incorrect |
1 ms |
336 KB |
Hair color 13 was used multiple times |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
336 KB |
OK (7 queries) |
3 |
Correct |
1 ms |
336 KB |
OK (4 queries) |
4 |
Incorrect |
1 ms |
336 KB |
Hair color 13 was used multiple times |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
336 KB |
OK (7 queries) |
3 |
Correct |
1 ms |
336 KB |
OK (4 queries) |
4 |
Incorrect |
1 ms |
336 KB |
Hair color 13 was used multiple times |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
336 KB |
OK (7 queries) |
3 |
Correct |
1 ms |
336 KB |
OK (4 queries) |
4 |
Incorrect |
1 ms |
336 KB |
Hair color 13 was used multiple times |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
336 KB |
OK (7 queries) |
3 |
Correct |
1 ms |
336 KB |
OK (4 queries) |
4 |
Incorrect |
1 ms |
336 KB |
Hair color 13 was used multiple times |
5 |
Halted |
0 ms |
0 KB |
- |