#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
int mmax=0,n;
vector<int> val[200005],none;
void Ask(int x) {
if (!val[x].size()) val[x]=ask(x);
}
void solve(int l, int r) { //l and r must be lolli_pop
Ask(l);
Ask(r);
if (val[r][0]==val[l][0]) return;
if (val[r][0]-val[l][0]==r-l-1) {
for (int i=l+1; i<r; ++i) none.push_back(i);
} else {
int mid=(l+r)/2;
Ask(mid);
if (val[mid][0]+val[mid][1]!=mmax) {
none.push_back(mid);
for (int i=mid-1; i>l; --i) {
Ask(i);
if (val[i][0]+val[i][1]!=mmax) none.push_back(i);
else {
solve(l,i);
break;
}
}
for (int i=mid+1; i<r; ++i) {
Ask(i);
if (val[i][0]+val[i][1]!=mmax) none.push_back(i);
else {
solve(i,r);
break;
}
}
} else {
solve(l,mid);
solve(mid,r);
}
}
}
int find_best(int N) {
n=N;
for (int i=0; i<min(475,n); ++i) {
Ask(i);
mmax=max(mmax,val[i][0]+val[i][1]);
}
int st,ed;
for (int i=0; i<n; ++i) {
Ask(i);
if (val[i][0]+val[i][1]!=mmax) none.push_back(i);
else {
st=i;
break;
}
}
for (int i=n-1; i>=0; --i) {
Ask(i);
if (val[i][0]+val[i][1]!=mmax) none.push_back(i);
else {
ed=i;
break;
}
}
solve(st,ed);
for (auto s : none) {
Ask(s);
if (val[s][0]+val[s][1]==0) return s;
}
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:82:1: warning: control reaches end of non-void function [-Wreturn-type]
82 | }
| ^
prize.cpp:76:10: warning: 'ed' may be used uninitialized in this function [-Wmaybe-uninitialized]
76 | solve(st,ed);
| ~~~~~^~~~~~~
prize.cpp:76:10: warning: 'st' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
5004 KB |
Output is correct |
2 |
Correct |
6 ms |
4944 KB |
Output is correct |
3 |
Correct |
6 ms |
5000 KB |
Output is correct |
4 |
Correct |
6 ms |
4944 KB |
Output is correct |
5 |
Correct |
5 ms |
4944 KB |
Output is correct |
6 |
Correct |
4 ms |
5000 KB |
Output is correct |
7 |
Correct |
6 ms |
4992 KB |
Output is correct |
8 |
Correct |
6 ms |
4944 KB |
Output is correct |
9 |
Correct |
5 ms |
5012 KB |
Output is correct |
10 |
Correct |
7 ms |
4996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
4996 KB |
Output is correct |
2 |
Correct |
5 ms |
4944 KB |
Output is correct |
3 |
Correct |
5 ms |
4992 KB |
Output is correct |
4 |
Correct |
6 ms |
4992 KB |
Output is correct |
5 |
Correct |
6 ms |
4944 KB |
Output is correct |
6 |
Correct |
7 ms |
5004 KB |
Output is correct |
7 |
Correct |
4 ms |
5092 KB |
Output is correct |
8 |
Correct |
7 ms |
5008 KB |
Output is correct |
9 |
Correct |
6 ms |
5012 KB |
Output is correct |
10 |
Correct |
5 ms |
5012 KB |
Output is correct |
11 |
Correct |
11 ms |
4980 KB |
Output is correct |
12 |
Correct |
6 ms |
5012 KB |
Output is correct |
13 |
Correct |
6 ms |
5004 KB |
Output is correct |
14 |
Correct |
15 ms |
4944 KB |
Output is correct |
15 |
Correct |
31 ms |
5004 KB |
Output is correct |
16 |
Partially correct |
21 ms |
5152 KB |
Partially correct - number of queries: 5092 |
17 |
Correct |
40 ms |
5120 KB |
Output is correct |
18 |
Partially correct |
35 ms |
5064 KB |
Partially correct - number of queries: 5089 |
19 |
Correct |
18 ms |
5132 KB |
Output is correct |
20 |
Correct |
23 ms |
5332 KB |
Output is correct |
21 |
Correct |
19 ms |
5236 KB |
Output is correct |
22 |
Correct |
16 ms |
5100 KB |
Output is correct |
23 |
Correct |
7 ms |
4944 KB |
Output is correct |
24 |
Correct |
7 ms |
5088 KB |
Output is correct |
25 |
Correct |
41 ms |
5120 KB |
Output is correct |
26 |
Correct |
37 ms |
5028 KB |
Output is correct |
27 |
Correct |
6 ms |
4988 KB |
Output is correct |
28 |
Correct |
38 ms |
5124 KB |
Output is correct |
29 |
Correct |
38 ms |
5064 KB |
Output is correct |
30 |
Partially correct |
40 ms |
5112 KB |
Partially correct - number of queries: 5063 |
31 |
Correct |
31 ms |
5072 KB |
Output is correct |
32 |
Correct |
11 ms |
4988 KB |
Output is correct |
33 |
Correct |
3 ms |
4944 KB |
Output is correct |
34 |
Correct |
42 ms |
5104 KB |
Output is correct |
35 |
Correct |
7 ms |
5124 KB |
Output is correct |
36 |
Correct |
43 ms |
5116 KB |
Output is correct |
37 |
Correct |
8 ms |
5028 KB |
Output is correct |
38 |
Correct |
7 ms |
5004 KB |
Output is correct |
39 |
Correct |
44 ms |
5064 KB |
Output is correct |
40 |
Correct |
21 ms |
5236 KB |
Output is correct |
41 |
Partially correct |
19 ms |
5228 KB |
Partially correct - number of queries: 5010 |
42 |
Partially correct |
35 ms |
5160 KB |
Partially correct - number of queries: 5010 |
43 |
Correct |
34 ms |
5124 KB |
Output is correct |
44 |
Partially correct |
41 ms |
5136 KB |
Partially correct - number of queries: 5002 |
45 |
Correct |
40 ms |
5016 KB |
Output is correct |
46 |
Correct |
32 ms |
5064 KB |
Output is correct |
47 |
Correct |
18 ms |
5136 KB |
Output is correct |
48 |
Partially correct |
43 ms |
5064 KB |
Partially correct - number of queries: 5023 |
49 |
Correct |
45 ms |
5116 KB |
Output is correct |
50 |
Partially correct |
34 ms |
5064 KB |
Partially correct - number of queries: 5097 |
51 |
Correct |
44 ms |
5040 KB |
Output is correct |
52 |
Correct |
40 ms |
5020 KB |
Output is correct |
53 |
Correct |
8 ms |
5064 KB |
Output is correct |
54 |
Correct |
28 ms |
5060 KB |
Output is correct |
55 |
Correct |
42 ms |
5108 KB |
Output is correct |
56 |
Partially correct |
20 ms |
5148 KB |
Partially correct - number of queries: 5071 |
57 |
Partially correct |
42 ms |
5032 KB |
Partially correct - number of queries: 5021 |
58 |
Partially correct |
31 ms |
5036 KB |
Partially correct - number of queries: 5037 |
59 |
Partially correct |
43 ms |
5136 KB |
Partially correct - number of queries: 5016 |
60 |
Correct |
42 ms |
5240 KB |
Output is correct |
61 |
Correct |
8 ms |
4988 KB |
Output is correct |
62 |
Correct |
6 ms |
4988 KB |
Output is correct |
63 |
Correct |
7 ms |
4944 KB |
Output is correct |
64 |
Correct |
4 ms |
5016 KB |
Output is correct |
65 |
Correct |
5 ms |
4944 KB |
Output is correct |
66 |
Correct |
6 ms |
5012 KB |
Output is correct |
67 |
Correct |
6 ms |
4992 KB |
Output is correct |
68 |
Correct |
6 ms |
4944 KB |
Output is correct |
69 |
Correct |
7 ms |
5008 KB |
Output is correct |
70 |
Correct |
5 ms |
4944 KB |
Output is correct |
71 |
Partially correct |
51 ms |
5020 KB |
Partially correct - number of queries: 5234 |
72 |
Correct |
10 ms |
5020 KB |
Output is correct |
73 |
Partially correct |
49 ms |
5132 KB |
Partially correct - number of queries: 5171 |
74 |
Partially correct |
33 ms |
5148 KB |
Partially correct - number of queries: 5198 |
75 |
Correct |
7 ms |
5000 KB |
Output is correct |
76 |
Correct |
39 ms |
5048 KB |
Output is correct |
77 |
Partially correct |
46 ms |
5136 KB |
Partially correct - number of queries: 5192 |
78 |
Correct |
11 ms |
5008 KB |
Output is correct |
79 |
Correct |
15 ms |
5116 KB |
Output is correct |
80 |
Partially correct |
20 ms |
5080 KB |
Partially correct - number of queries: 5160 |
81 |
Partially correct |
48 ms |
5140 KB |
Partially correct - number of queries: 5185 |
82 |
Partially correct |
46 ms |
5048 KB |
Partially correct - number of queries: 5132 |
83 |
Correct |
7 ms |
4944 KB |
Output is correct |
84 |
Correct |
28 ms |
5052 KB |
Output is correct |
85 |
Partially correct |
48 ms |
5064 KB |
Partially correct - number of queries: 5167 |
86 |
Correct |
5 ms |
5008 KB |
Output is correct |
87 |
Correct |
8 ms |
4944 KB |
Output is correct |
88 |
Correct |
4 ms |
5016 KB |
Output is correct |
89 |
Correct |
6 ms |
4944 KB |
Output is correct |
90 |
Correct |
6 ms |
4988 KB |
Output is correct |
91 |
Correct |
6 ms |
4944 KB |
Output is correct |
92 |
Correct |
5 ms |
4944 KB |
Output is correct |
93 |
Correct |
8 ms |
5012 KB |
Output is correct |
94 |
Correct |
9 ms |
5004 KB |
Output is correct |
95 |
Correct |
9 ms |
5000 KB |
Output is correct |
96 |
Correct |
7 ms |
4996 KB |
Output is correct |
97 |
Correct |
7 ms |
4944 KB |
Output is correct |