#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int>vi;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x),end(x)
#define FOR(i,a,b) for(int i=a; i<b; i++)
//-----------------------------------------------------
const int MX=2e5+10;
int memo[MX][2];
int cnt=0;
vi query(int i){
if(memo[i][0]==-1){
cnt++;
if(cnt>10000) assert(0);
vi vec=ask(i);
memo[i][0]=vec[0];
memo[i][1]=vec[1];
}
return vi{memo[i][0],memo[i][1]};
}
int sq(int x){
return x*x;
}
int find_best(int N){
memset(memo,-1,sizeof(memo));
int lft=0;
while(lft<N){
vi v=query(lft);
if(v[0]+v[1]==0) return lft;
int l=lft,r=min(N-1,lft+1000),rgt;
while(l<=r){
int m=(l+r)/2;
vi vv=query(m);
if(v[0]+v[1]!=vv[0]+vv[1])
r=m-1;
else{
if(v[0]==vv[0]){
rgt=m;
l=m+1;
}
else r=m-1;
}
}
lft=rgt+1;
}
return 0;
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:60:6: warning: 'rgt' may be used uninitialized in this function [-Wmaybe-uninitialized]
60 | lft=rgt+1;
| ~~~^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1824 KB |
Output is correct |
2 |
Correct |
20 ms |
1736 KB |
Output is correct |
3 |
Correct |
12 ms |
1728 KB |
Output is correct |
4 |
Correct |
24 ms |
1736 KB |
Output is correct |
5 |
Correct |
18 ms |
1824 KB |
Output is correct |
6 |
Correct |
2 ms |
1820 KB |
Output is correct |
7 |
Correct |
17 ms |
1824 KB |
Output is correct |
8 |
Correct |
18 ms |
1832 KB |
Output is correct |
9 |
Correct |
16 ms |
1824 KB |
Output is correct |
10 |
Correct |
36 ms |
1792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1828 KB |
Output is correct |
2 |
Correct |
12 ms |
1820 KB |
Output is correct |
3 |
Correct |
13 ms |
1832 KB |
Output is correct |
4 |
Correct |
34 ms |
1824 KB |
Output is correct |
5 |
Correct |
11 ms |
1824 KB |
Output is correct |
6 |
Correct |
2 ms |
1736 KB |
Output is correct |
7 |
Correct |
17 ms |
1804 KB |
Output is correct |
8 |
Correct |
13 ms |
1808 KB |
Output is correct |
9 |
Correct |
26 ms |
1804 KB |
Output is correct |
10 |
Correct |
22 ms |
1736 KB |
Output is correct |
11 |
Correct |
15 ms |
1816 KB |
Output is correct |
12 |
Correct |
2 ms |
1808 KB |
Output is correct |
13 |
Correct |
38 ms |
1828 KB |
Output is correct |
14 |
Correct |
7 ms |
1736 KB |
Output is correct |
15 |
Correct |
13 ms |
1824 KB |
Output is correct |
16 |
Partially correct |
100 ms |
1808 KB |
Partially correct - number of queries: 7210 |
17 |
Correct |
2 ms |
1816 KB |
Output is correct |
18 |
Partially correct |
74 ms |
1828 KB |
Partially correct - number of queries: 8685 |
19 |
Correct |
2 ms |
1824 KB |
Output is correct |
20 |
Correct |
31 ms |
1736 KB |
Output is correct |
21 |
Correct |
43 ms |
1824 KB |
Output is correct |
22 |
Correct |
4 ms |
1816 KB |
Output is correct |
23 |
Correct |
5 ms |
1736 KB |
Output is correct |
24 |
Correct |
2 ms |
1736 KB |
Output is correct |
25 |
Correct |
55 ms |
1736 KB |
Output is correct |
26 |
Correct |
75 ms |
1728 KB |
Output is correct |
27 |
Correct |
9 ms |
1736 KB |
Output is correct |
28 |
Partially correct |
114 ms |
1828 KB |
Partially correct - number of queries: 8253 |
29 |
Partially correct |
39 ms |
1816 KB |
Partially correct - number of queries: 6468 |
30 |
Partially correct |
120 ms |
1816 KB |
Partially correct - number of queries: 8767 |
31 |
Correct |
1 ms |
1736 KB |
Output is correct |
32 |
Correct |
24 ms |
1728 KB |
Output is correct |
33 |
Correct |
2 ms |
1736 KB |
Output is correct |
34 |
Correct |
36 ms |
1820 KB |
Output is correct |
35 |
Correct |
22 ms |
1728 KB |
Output is correct |
36 |
Correct |
25 ms |
1820 KB |
Output is correct |
37 |
Correct |
8 ms |
1828 KB |
Output is correct |
38 |
Correct |
5 ms |
1816 KB |
Output is correct |
39 |
Correct |
53 ms |
1812 KB |
Output is correct |
40 |
Partially correct |
103 ms |
1820 KB |
Partially correct - number of queries: 6455 |
41 |
Correct |
24 ms |
1808 KB |
Output is correct |
42 |
Correct |
25 ms |
1824 KB |
Output is correct |
43 |
Correct |
62 ms |
1820 KB |
Output is correct |
44 |
Correct |
20 ms |
1808 KB |
Output is correct |
45 |
Correct |
16 ms |
1824 KB |
Output is correct |
46 |
Correct |
2 ms |
1804 KB |
Output is correct |
47 |
Correct |
60 ms |
1804 KB |
Output is correct |
48 |
Partially correct |
79 ms |
1808 KB |
Partially correct - number of queries: 6251 |
49 |
Correct |
14 ms |
1728 KB |
Output is correct |
50 |
Partially correct |
135 ms |
1736 KB |
Partially correct - number of queries: 8640 |
51 |
Correct |
37 ms |
1736 KB |
Output is correct |
52 |
Correct |
2 ms |
1816 KB |
Output is correct |
53 |
Correct |
32 ms |
1828 KB |
Output is correct |
54 |
Correct |
30 ms |
1736 KB |
Output is correct |
55 |
Correct |
1 ms |
1804 KB |
Output is correct |
56 |
Partially correct |
66 ms |
1820 KB |
Partially correct - number of queries: 8677 |
57 |
Partially correct |
76 ms |
1736 KB |
Partially correct - number of queries: 5934 |
58 |
Partially correct |
31 ms |
1804 KB |
Partially correct - number of queries: 6116 |
59 |
Correct |
41 ms |
1808 KB |
Output is correct |
60 |
Correct |
51 ms |
1736 KB |
Output is correct |
61 |
Correct |
28 ms |
1816 KB |
Output is correct |
62 |
Correct |
4 ms |
1736 KB |
Output is correct |
63 |
Correct |
11 ms |
1816 KB |
Output is correct |
64 |
Correct |
22 ms |
1820 KB |
Output is correct |
65 |
Correct |
12 ms |
1856 KB |
Output is correct |
66 |
Correct |
21 ms |
1828 KB |
Output is correct |
67 |
Correct |
19 ms |
1736 KB |
Output is correct |
68 |
Correct |
2 ms |
1728 KB |
Output is correct |
69 |
Correct |
27 ms |
1728 KB |
Output is correct |
70 |
Correct |
35 ms |
1820 KB |
Output is correct |
71 |
Partially correct |
96 ms |
1736 KB |
Partially correct - number of queries: 8488 |
72 |
Correct |
26 ms |
1736 KB |
Output is correct |
73 |
Partially correct |
123 ms |
1736 KB |
Partially correct - number of queries: 8362 |
74 |
Partially correct |
81 ms |
1736 KB |
Partially correct - number of queries: 8415 |
75 |
Correct |
22 ms |
1736 KB |
Output is correct |
76 |
Partially correct |
116 ms |
1736 KB |
Partially correct - number of queries: 7454 |
77 |
Partially correct |
42 ms |
1864 KB |
Partially correct - number of queries: 8524 |
78 |
Correct |
28 ms |
1736 KB |
Output is correct |
79 |
Correct |
32 ms |
1736 KB |
Output is correct |
80 |
Partially correct |
82 ms |
1736 KB |
Partially correct - number of queries: 8553 |
81 |
Partially correct |
96 ms |
1736 KB |
Partially correct - number of queries: 8570 |
82 |
Partially correct |
114 ms |
1736 KB |
Partially correct - number of queries: 8546 |
83 |
Correct |
22 ms |
1736 KB |
Output is correct |
84 |
Partially correct |
75 ms |
1736 KB |
Partially correct - number of queries: 7363 |
85 |
Partially correct |
139 ms |
1736 KB |
Partially correct - number of queries: 8534 |
86 |
Correct |
29 ms |
1884 KB |
Output is correct |
87 |
Correct |
21 ms |
1736 KB |
Output is correct |
88 |
Correct |
25 ms |
1736 KB |
Output is correct |
89 |
Correct |
14 ms |
1736 KB |
Output is correct |
90 |
Correct |
22 ms |
1828 KB |
Output is correct |
91 |
Correct |
23 ms |
1736 KB |
Output is correct |
92 |
Correct |
27 ms |
1736 KB |
Output is correct |
93 |
Correct |
27 ms |
1736 KB |
Output is correct |
94 |
Correct |
26 ms |
1736 KB |
Output is correct |
95 |
Correct |
37 ms |
1736 KB |
Output is correct |
96 |
Correct |
38 ms |
1736 KB |
Output is correct |
97 |
Correct |
30 ms |
1736 KB |
Output is correct |