# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1017821 |
2024-07-09T10:28:23 Z |
Gray |
Colors (BOI20_colors) |
C++17 |
|
1 ms |
344 KB |
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#define ll long long
#define ln "\n"
#define ff first
#define ss second
#define ull unsigned ll
#define ld long double
const ll INF = 1e9;
const ll MOD = 1e9+7;
using namespace std;
void solve(){
ll n; cin >> n;
vector<bool> usd(n+1);
ll l=0, r=n;
vector<ll> moves;
while (l+1<r) moves.push_back((r+l)/2), l=(r+l)/2;
ll sp=1;
for (ll i=moves.size()-1; i>=0; i--){
if (sp+moves[i]<=n) sp+=moves[i];
else sp-=moves[i];
}
usd[sp]=1;
cout << "? " << sp << endl; ll _; cin >> _;
l=0, r=n; ll lp=sp;
while (l+1<r){
ll mid = (l+r)/2;
if (lp-mid>=0 and !usd[lp-mid]){
lp=lp-mid;
cout << "? " << lp << endl;
}else{
lp=lp+mid;
cout << "? " << lp << endl;
}
usd[lp]=1;
ll x; cin >> x;
if (x) r=mid;
else l=mid;
}
cout << "= " << r << endl;
}
// 123456789
// #.####.#.
void setIO(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int main(){
setIO();
ll t=1;
// cin >> t;
while (t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
344 KB |
OK (7 queries) |
3 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
4 |
Correct |
0 ms |
344 KB |
OK (5 queries) |
5 |
Correct |
0 ms |
344 KB |
OK (5 queries) |
6 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
7 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
344 KB |
OK (6 queries) |
9 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
10 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
344 KB |
OK (7 queries) |
3 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
4 |
Correct |
0 ms |
344 KB |
OK (5 queries) |
5 |
Correct |
0 ms |
344 KB |
OK (5 queries) |
6 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
7 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
344 KB |
OK (6 queries) |
9 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
10 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
344 KB |
OK (7 queries) |
3 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
4 |
Correct |
0 ms |
344 KB |
OK (5 queries) |
5 |
Correct |
0 ms |
344 KB |
OK (5 queries) |
6 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
7 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
344 KB |
OK (6 queries) |
9 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
10 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
344 KB |
OK (7 queries) |
3 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
4 |
Correct |
0 ms |
344 KB |
OK (5 queries) |
5 |
Correct |
0 ms |
344 KB |
OK (5 queries) |
6 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
7 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
344 KB |
OK (6 queries) |
9 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
10 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
2 |
Correct |
1 ms |
344 KB |
OK (7 queries) |
3 |
Correct |
0 ms |
344 KB |
OK (4 queries) |
4 |
Correct |
0 ms |
344 KB |
OK (5 queries) |
5 |
Correct |
0 ms |
344 KB |
OK (5 queries) |
6 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
7 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
8 |
Correct |
1 ms |
344 KB |
OK (6 queries) |
9 |
Correct |
0 ms |
344 KB |
OK (7 queries) |
10 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
11 |
Halted |
0 ms |
0 KB |
- |