#include <bits/stdc++.h>
#include "prize.h"
//#include "Lgrader.cpp"
using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);
vector<int> memo[MAXN];
int Q = 0;
vector<int> query(int i)
{
if(memo[i].empty()) memo[i] = ask(i), Q++;
if(Q == 10000) assert(false);
return memo[i];
}
void rec(int l, int r)
{
if(r < l) return;
int mid = (l + r) >> 1;
if(query(l - 1) == query(mid))
for(int i = l; i < mid; i++)
memo[i] = query(mid);
else
rec(l, mid - 1);
if(query(mid) == query(r + 1))
for(int i = mid + 1; i <= r; i++)
memo[i] = query(mid);
else
rec(mid + 1, r);
}
int find_best(int n)
{
/*int i = 0;
while(i < n)
{
auto curr = query(i);
if(curr[0] == 0 && curr[1] == 0)
return i;
int low = i, high = n - 1, mid, ret;
for(int l = 0; low + (1 << l) < n; l++)
{
if(curr != query(low + (1 << l)))
{
high = low + (1 << l);
break;
}
low += (1 << l);
}
while(low <= high)
{
mid = (low + high) >> 1;
if(curr == query(mid))
low = mid + 1, ret = mid;
else
high = mid - 1;
}
i = ret + 1;
}*/
rec(1, n - 2);
for(int i = 0; i < n; i++)
if(query(i)[0] + query(i)[1] == 0)
return i;
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
31096 KB |
Output is correct |
2 |
Correct |
49 ms |
31284 KB |
Output is correct |
3 |
Correct |
44 ms |
31284 KB |
Output is correct |
4 |
Correct |
56 ms |
31284 KB |
Output is correct |
5 |
Correct |
46 ms |
31344 KB |
Output is correct |
6 |
Correct |
37 ms |
31344 KB |
Output is correct |
7 |
Correct |
45 ms |
31360 KB |
Output is correct |
8 |
Correct |
48 ms |
31372 KB |
Output is correct |
9 |
Correct |
46 ms |
31416 KB |
Output is correct |
10 |
Correct |
56 ms |
31416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
31420 KB |
Output is correct |
2 |
Correct |
49 ms |
31420 KB |
Output is correct |
3 |
Correct |
47 ms |
31420 KB |
Output is correct |
4 |
Correct |
57 ms |
31420 KB |
Output is correct |
5 |
Correct |
47 ms |
31420 KB |
Output is correct |
6 |
Correct |
41 ms |
31420 KB |
Output is correct |
7 |
Correct |
49 ms |
31420 KB |
Output is correct |
8 |
Correct |
50 ms |
31420 KB |
Output is correct |
9 |
Correct |
50 ms |
31420 KB |
Output is correct |
10 |
Correct |
55 ms |
31424 KB |
Output is correct |
11 |
Correct |
53 ms |
31424 KB |
Output is correct |
12 |
Correct |
44 ms |
31424 KB |
Output is correct |
13 |
Correct |
59 ms |
31424 KB |
Output is correct |
14 |
Correct |
31 ms |
31424 KB |
Output is correct |
15 |
Correct |
87 ms |
31424 KB |
Output is correct |
16 |
Partially correct |
98 ms |
31424 KB |
Partially correct - number of queries: 5039 |
17 |
Partially correct |
63 ms |
31424 KB |
Partially correct - number of queries: 5073 |
18 |
Partially correct |
87 ms |
31436 KB |
Partially correct - number of queries: 5069 |
19 |
Correct |
64 ms |
31436 KB |
Output is correct |
20 |
Correct |
72 ms |
31436 KB |
Output is correct |
21 |
Partially correct |
98 ms |
31436 KB |
Partially correct - number of queries: 5021 |
22 |
Correct |
71 ms |
31436 KB |
Output is correct |
23 |
Correct |
49 ms |
31436 KB |
Output is correct |
24 |
Correct |
52 ms |
31436 KB |
Output is correct |
25 |
Correct |
92 ms |
31436 KB |
Output is correct |
26 |
Correct |
85 ms |
31436 KB |
Output is correct |
27 |
Correct |
48 ms |
31436 KB |
Output is correct |
28 |
Correct |
92 ms |
31436 KB |
Output is correct |
29 |
Correct |
86 ms |
31436 KB |
Output is correct |
30 |
Partially correct |
107 ms |
31440 KB |
Partially correct - number of queries: 5023 |
31 |
Partially correct |
80 ms |
31440 KB |
Partially correct - number of queries: 5028 |
32 |
Correct |
65 ms |
31440 KB |
Output is correct |
33 |
Correct |
26 ms |
31440 KB |
Output is correct |
34 |
Partially correct |
94 ms |
31440 KB |
Partially correct - number of queries: 5057 |
35 |
Correct |
50 ms |
31444 KB |
Output is correct |
36 |
Partially correct |
90 ms |
31444 KB |
Partially correct - number of queries: 5065 |
37 |
Correct |
47 ms |
31444 KB |
Output is correct |
38 |
Correct |
56 ms |
31444 KB |
Output is correct |
39 |
Partially correct |
94 ms |
31444 KB |
Partially correct - number of queries: 5063 |
40 |
Correct |
92 ms |
31444 KB |
Output is correct |
41 |
Partially correct |
80 ms |
31444 KB |
Partially correct - number of queries: 5094 |
42 |
Partially correct |
98 ms |
31444 KB |
Partially correct - number of queries: 5094 |
43 |
Correct |
75 ms |
31444 KB |
Output is correct |
44 |
Partially correct |
87 ms |
31444 KB |
Partially correct - number of queries: 5061 |
45 |
Correct |
78 ms |
31444 KB |
Output is correct |
46 |
Partially correct |
71 ms |
31444 KB |
Partially correct - number of queries: 5069 |
47 |
Correct |
99 ms |
31444 KB |
Output is correct |
48 |
Partially correct |
91 ms |
31444 KB |
Partially correct - number of queries: 5081 |
49 |
Partially correct |
95 ms |
31444 KB |
Partially correct - number of queries: 5083 |
50 |
Partially correct |
89 ms |
31444 KB |
Partially correct - number of queries: 5070 |
51 |
Partially correct |
102 ms |
31444 KB |
Partially correct - number of queries: 5073 |
52 |
Partially correct |
85 ms |
31444 KB |
Partially correct - number of queries: 5062 |
53 |
Correct |
55 ms |
31444 KB |
Output is correct |
54 |
Partially correct |
85 ms |
31444 KB |
Partially correct - number of queries: 5029 |
55 |
Partially correct |
76 ms |
31444 KB |
Partially correct - number of queries: 5071 |
56 |
Partially correct |
158 ms |
31444 KB |
Partially correct - number of queries: 5080 |
57 |
Partially correct |
100 ms |
31444 KB |
Partially correct - number of queries: 5019 |
58 |
Partially correct |
93 ms |
31444 KB |
Partially correct - number of queries: 5096 |
59 |
Partially correct |
93 ms |
31444 KB |
Partially correct - number of queries: 5072 |
60 |
Partially correct |
73 ms |
31444 KB |
Partially correct - number of queries: 5071 |
61 |
Correct |
53 ms |
31444 KB |
Output is correct |
62 |
Correct |
41 ms |
31444 KB |
Output is correct |
63 |
Correct |
56 ms |
31444 KB |
Output is correct |
64 |
Correct |
48 ms |
31444 KB |
Output is correct |
65 |
Correct |
58 ms |
31444 KB |
Output is correct |
66 |
Correct |
56 ms |
31444 KB |
Output is correct |
67 |
Correct |
55 ms |
31444 KB |
Output is correct |
68 |
Correct |
37 ms |
31444 KB |
Output is correct |
69 |
Correct |
62 ms |
31444 KB |
Output is correct |
70 |
Correct |
64 ms |
31444 KB |
Output is correct |
71 |
Correct |
134 ms |
31444 KB |
Output is correct |
72 |
Correct |
83 ms |
31444 KB |
Output is correct |
73 |
Correct |
115 ms |
31516 KB |
Output is correct |
74 |
Correct |
104 ms |
31516 KB |
Output is correct |
75 |
Correct |
57 ms |
31516 KB |
Output is correct |
76 |
Correct |
93 ms |
31516 KB |
Output is correct |
77 |
Partially correct |
107 ms |
31516 KB |
Partially correct - number of queries: 5215 |
78 |
Correct |
59 ms |
31516 KB |
Output is correct |
79 |
Correct |
77 ms |
31516 KB |
Output is correct |
80 |
Partially correct |
132 ms |
31516 KB |
Partially correct - number of queries: 5246 |
81 |
Partially correct |
122 ms |
31604 KB |
Partially correct - number of queries: 5218 |
82 |
Partially correct |
124 ms |
31604 KB |
Partially correct - number of queries: 5215 |
83 |
Correct |
57 ms |
31604 KB |
Output is correct |
84 |
Correct |
105 ms |
31604 KB |
Output is correct |
85 |
Partially correct |
145 ms |
31604 KB |
Partially correct - number of queries: 5265 |
86 |
Correct |
99 ms |
31604 KB |
Output is correct |
87 |
Correct |
59 ms |
31604 KB |
Output is correct |
88 |
Correct |
62 ms |
31604 KB |
Output is correct |
89 |
Correct |
62 ms |
31604 KB |
Output is correct |
90 |
Correct |
56 ms |
31604 KB |
Output is correct |
91 |
Correct |
60 ms |
31604 KB |
Output is correct |
92 |
Correct |
55 ms |
31604 KB |
Output is correct |
93 |
Correct |
55 ms |
31604 KB |
Output is correct |
94 |
Correct |
60 ms |
31604 KB |
Output is correct |
95 |
Correct |
59 ms |
31604 KB |
Output is correct |
96 |
Correct |
62 ms |
31604 KB |
Output is correct |
97 |
Correct |
54 ms |
31604 KB |
Output is correct |