# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
492701 |
2021-12-08T12:54:45 Z |
zhougz |
Colors (BOI20_colors) |
C++17 |
|
1 ms |
200 KB |
/**
* author: chowgz
* created: 13/04/2021 20:13:22
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int tt;
cin >> tt;
while (tt--) {
long long n;
cin >> n;
long long l = 1, r = n - 1, m = (l + r) / 2;
stack<long long> s;
while (m != n - 1) {
m = (l + r) / 2;
s.push(m);
l = m + 1;
}
long long cur = n;
bool up = false;
while (!s.empty()) {
cur += up ? s.top() : -s.top();
up = !up;
s.pop();
}
bool yes;
auto ask = [&](long long x) {
cur += up ? x : -x;
up = !up;
cout << "? " << cur << endl;
cout.flush();
cin >> yes;
};
cout << "? " << cur << endl;
cout.flush();
cin >> yes;
l = 1;
r = n - 1;
m = (l + r) / 2;
long long ans = n;
while (l <= r) {
ask(m);
if (yes) {
ans = m;
r = m - 1;
} else {
l = m + 1;
}
m = (l + r) / 2;
}
cout << "= " << ans << endl;
cout.flush();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
200 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
200 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
200 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
200 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
200 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |