# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
553790 |
2022-04-27T05:37:03 Z |
Arvin |
Colors (BOI20_colors) |
C++11 |
|
1 ms |
208 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool ask(ll n){
cout << "? " << n << endl;
bool res;
cin >> res;
return res;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
ask(1);
set<ll> st;
st.insert(1);
ll pos = 1;
ll ans = 0;
ll lg = log2(n);
for(int x=lg;x>=0;x--){
ll val = min(n-1, ans|((1 << x)-1));
while((pos+val > n || st.count(pos+val)) && (pos-val <= 0 || st.count(pos-val))){
if(pos >= n) break;
pos++;
}
while((pos+val > n || st.count(pos+val)) && (pos-val <= 0 || st.count(pos-val))){
if(pos <= 1) break;
pos--;
}
if(!st.count(pos)){
st.insert(pos);
ask(pos);
}
if(pos+val <= n && !st.count(pos+val)){
if(!ask(pos+val)){
ans |= (1 << x);
}
pos += val;
} else if(pos-val > 0 && !st.count(pos-val)){
if(!ask(pos-val)){
ans |= (1 << x);
}
pos -= val;
}
st.insert(pos);
}
cout << "= " << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
2 |
Correct |
0 ms |
208 KB |
OK (9 queries) |
3 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
4 |
Incorrect |
0 ms |
208 KB |
Integer parameter [name=k] equals to 0, violates the range [1, 26] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
2 |
Correct |
0 ms |
208 KB |
OK (9 queries) |
3 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
4 |
Incorrect |
0 ms |
208 KB |
Integer parameter [name=k] equals to 0, violates the range [1, 26] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
2 |
Correct |
0 ms |
208 KB |
OK (9 queries) |
3 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
4 |
Incorrect |
0 ms |
208 KB |
Integer parameter [name=k] equals to 0, violates the range [1, 26] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
2 |
Correct |
0 ms |
208 KB |
OK (9 queries) |
3 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
4 |
Incorrect |
0 ms |
208 KB |
Integer parameter [name=k] equals to 0, violates the range [1, 26] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
2 |
Correct |
0 ms |
208 KB |
OK (9 queries) |
3 |
Correct |
1 ms |
208 KB |
OK (5 queries) |
4 |
Incorrect |
0 ms |
208 KB |
Integer parameter [name=k] equals to 0, violates the range [1, 26] |
5 |
Halted |
0 ms |
0 KB |
- |