# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
553826 |
2022-04-27T06:59:28 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 = 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 |
0 ms |
208 KB |
OK (6 queries) |
2 |
Incorrect |
1 ms |
208 KB |
Hair color 49 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (6 queries) |
2 |
Incorrect |
1 ms |
208 KB |
Hair color 49 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (6 queries) |
2 |
Incorrect |
1 ms |
208 KB |
Hair color 49 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (6 queries) |
2 |
Incorrect |
1 ms |
208 KB |
Hair color 49 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
OK (6 queries) |
2 |
Incorrect |
1 ms |
208 KB |
Hair color 49 was used multiple times |
3 |
Halted |
0 ms |
0 KB |
- |