#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;
bool visited[maxn];
int find_best(int n) {
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
srand(time(NULL));
if(n <= 10000) {
for(int i=1;i<=n;i++) {
vector<int>v = ask(i);
if(v[0] == v[1]) return i;
}
}
int fst = 0, lst = INT_MAX;
for(int i=1;i<=9000;i++) {
int x = uniform_int_distribution<int>(0, n)(rng);
while(visited[x]) x = uniform_int_distribution<int>(0, n)(rng);
visited[x] = true;
vector<int>v = ask(x);
if(v[0] == v[1]) return x;
// looking for the last {0, 1}
// looking for the first {1, 0}
if(v[0] == 0) fst = max(fst, x);
else if(v[0] == 1) lst = min(lst, x);
}
for(int i=fst;i<=lst;i++) {
vector<int>v = ask(i);
if(v[0] == v[1]) return i;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
576 KB |
Output is correct |
2 |
Correct |
65 ms |
504 KB |
Output is correct |
3 |
Correct |
29 ms |
512 KB |
Output is correct |
4 |
Correct |
82 ms |
504 KB |
Output is correct |
5 |
Correct |
32 ms |
704 KB |
Output is correct |
6 |
Correct |
58 ms |
512 KB |
Output is correct |
7 |
Correct |
20 ms |
500 KB |
Output is correct |
8 |
Correct |
55 ms |
504 KB |
Output is correct |
9 |
Correct |
96 ms |
512 KB |
Output is correct |
10 |
Correct |
110 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
58 ms |
572 KB |
Partially correct - number of queries: 9016 |
2 |
Partially correct |
115 ms |
504 KB |
Partially correct - number of queries: 9021 |
3 |
Partially correct |
60 ms |
512 KB |
Partially correct - number of queries: 9014 |
4 |
Partially correct |
71 ms |
512 KB |
Partially correct - number of queries: 9033 |
5 |
Partially correct |
57 ms |
504 KB |
Partially correct - number of queries: 9011 |
6 |
Partially correct |
86 ms |
504 KB |
Partially correct - number of queries: 9001 |
7 |
Partially correct |
89 ms |
504 KB |
Partially correct - number of queries: 9041 |
8 |
Partially correct |
68 ms |
424 KB |
Partially correct - number of queries: 9005 |
9 |
Correct |
26 ms |
512 KB |
Output is correct |
10 |
Partially correct |
63 ms |
512 KB |
Partially correct - number of queries: 9060 |
11 |
Incorrect |
2 ms |
256 KB |
answer is not correct |
12 |
Halted |
0 ms |
0 KB |
- |