#include<bits/stdc++.h>
#include "prize.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int pos;
vector<int> solve(int l,int r,vector<int> tar){
if(pos!=-1) return vector<int>({0,0});
if(l==r){
vector<int> q=ask(l);
if(q[0]==0 && q[1]==0) pos=l;
return q;
}
int mid=(l+r)>>1;
vector<int> q=ask(mid+1);
if(q[0]==0 && q[1]==0) pos=mid+1;
if(pos!=-1) return vector<int>({0,0});
if(q[0]!=tar[0] || q[1]!=tar[1]) tar=solve(mid+1,r,tar);
if(pos!=-1) return vector<int>({0,0});
return solve(l,mid,tar);
}
int find_best(int n) {
pos=-1;
solve(0,n-1,ask(n-1));
if(pos==-1) assert(false);
return pos;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
520 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
432 KB |
Output is correct |
7 |
Correct |
2 ms |
312 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
324 KB |
Output is correct |
10 |
Correct |
3 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
256 KB |
Output is correct |
11 |
Correct |
12 ms |
384 KB |
Output is correct |
12 |
Correct |
15 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
16 ms |
396 KB |
Output is correct |
15 |
Incorrect |
63 ms |
388 KB |
Incorrect |
16 |
Halted |
0 ms |
0 KB |
- |