# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
553816 |
2022-04-27T06:48:00 Z |
Arvin |
Colors (BOI20_colors) |
C++11 |
|
1 ms |
208 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
set<ll> st;
bool ask(ll n){
cout << "? " << n << endl;
st.insert(n);
int res;
cin >> res;
return (res == 1);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
ll ans = n;
ll pos = (n+1)/2;
ask(pos);
ll cur = 1;
ll left = 1, right = n-1;
while(left <= right){
ll mid = (left+right) >> 1;
while(st.count(cur)){
cur++;
}
bool valid = false;
if(pos-mid > 0 && !st.count(pos-mid)){
if(ask(pos-mid)){
valid = true;
} else {
valid = false;
}
pos -= mid;
} else if(pos+mid <= n && !st.count(pos+mid)){
if(ask(pos+mid)){
valid = true;
} else {
valid = false;
}
pos += mid;
} else {
ask(cur);
pos = cur;
if(ask(pos+mid)){
valid = true;
} else {
valid = false;
}
pos += mid;
}
if(valid){
ans = mid;
right = mid-1;
} else {
left = mid+1;
}
}
cout << "= " << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
208 KB |
OK (9 queries) |
3 |
Correct |
0 ms |
208 KB |
OK (4 queries) |
4 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
5 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
6 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
7 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
9 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
10 |
Correct |
1 ms |
208 KB |
OK (4 queries) |
11 |
Correct |
0 ms |
208 KB |
OK (6 queries) |
12 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
13 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
14 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
15 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
16 |
Correct |
0 ms |
208 KB |
OK (7 queries) |
17 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
208 KB |
OK (9 queries) |
3 |
Correct |
0 ms |
208 KB |
OK (4 queries) |
4 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
5 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
6 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
7 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
9 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
10 |
Correct |
1 ms |
208 KB |
OK (4 queries) |
11 |
Correct |
0 ms |
208 KB |
OK (6 queries) |
12 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
13 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
14 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
15 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
16 |
Correct |
0 ms |
208 KB |
OK (7 queries) |
17 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
208 KB |
OK (9 queries) |
3 |
Correct |
0 ms |
208 KB |
OK (4 queries) |
4 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
5 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
6 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
7 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
9 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
10 |
Correct |
1 ms |
208 KB |
OK (4 queries) |
11 |
Correct |
0 ms |
208 KB |
OK (6 queries) |
12 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
13 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
14 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
15 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
16 |
Correct |
0 ms |
208 KB |
OK (7 queries) |
17 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
208 KB |
OK (9 queries) |
3 |
Correct |
0 ms |
208 KB |
OK (4 queries) |
4 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
5 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
6 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
7 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
9 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
10 |
Correct |
1 ms |
208 KB |
OK (4 queries) |
11 |
Correct |
0 ms |
208 KB |
OK (6 queries) |
12 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
13 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
14 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
15 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
16 |
Correct |
0 ms |
208 KB |
OK (7 queries) |
17 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
208 KB |
OK (9 queries) |
3 |
Correct |
0 ms |
208 KB |
OK (4 queries) |
4 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
5 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
6 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
7 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
9 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
10 |
Correct |
1 ms |
208 KB |
OK (4 queries) |
11 |
Correct |
0 ms |
208 KB |
OK (6 queries) |
12 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
13 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
14 |
Correct |
1 ms |
208 KB |
OK (7 queries) |
15 |
Correct |
1 ms |
208 KB |
OK (8 queries) |
16 |
Correct |
0 ms |
208 KB |
OK (7 queries) |
17 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |