# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1085993 |
2024-09-09T09:05:53 Z |
not_amir |
Colors (BOI20_colors) |
C++14 |
|
0 ms |
344 KB |
#include <bits/stdc++.h>
using namespace std;
#define T
typedef long long ll;
ll C, n;
int ask(ll q){
static ll bef = 0;
cout << "? " << q << endl;
int ans;
#ifdef T
if(q < 1 || q > n){
cout << "INVALID";
exit(1);
}
cout << (abs(q - bef) < C?ans=0:ans=1) << endl;
bef = q;
#else
cin >> ans;
#endif
return ans;
}
ll solve(ll n, ll c, ll add, bool dir){
if(n == 1)
return 1 + add;
ll diff = n/2 + add;
ll q = (dir)?c+diff:c-diff;
if(ask(q))
return solve((n+1)/2, q, add, !dir);
else
return solve((n+1)/2, q, add + n/2, !dir);
}
ll start(ll N){
if(N == 1)
return 1;
return (N + 1)/2 + 1 - start((N + 1)/2);
}
int main(){
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
#ifdef T
srand(time(NULL));
n = rand();
C = rand()%n + 1;
cout << n << ' ' << C << endl;
#else
cin >> n;
#endif
int c = start(n);
ask(c);
ll ans = solve(n, c, 0, c<(n+1)/2?1:0);
cout << "= " << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Token parameter [name=cmd] equals to "242929859", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Token parameter [name=cmd] equals to "242929859", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Token parameter [name=cmd] equals to "242929859", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Token parameter [name=cmd] equals to "242929859", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Token parameter [name=cmd] equals to "242929859", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |