// 12:10
#include "prize.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
//#define int long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/
using namespace std;
const int N = 200005;
int a[N], b[N], F[N];
int Q;
void mak (int x){
if (F[x])
return;
vector < int > res = ask (x);
a[x] = res[0];
b[x] = res[1];
F[x] = 1;
Q++;
if (Q > 4760)
assert (0);
}
int m;
vector < int > solve (int l, int r, int L, int R){
vector < int > ans;
if (l > r || L > R)
return ans;
int mid = l + r >> 1;
while (mid >= l){
mak (mid);
if (a[mid] + b[mid] == m)
break;
ans.pb (mid);
mid--;
}
int le = mid-1;
int ri = (l+r>>1)+1;
int LL = L-1;
if (mid >= l)
LL = a[mid];
int RR = LL + 1 + (int)ans.size();
vector < int > A = solve (l, le, L, LL);
vector < int > B = solve (ri, r, RR, R);
for (int x : A)
ans.pb (x);
for (int x : B)
ans.pb (x);
return ans;
}
int find_best(int n) {
m = min (n-1, 446);
vector < int > V;
for (int i = 0; i < n; i++)
V.pb (i);
for (int i = 0; i < 20; i++)
random_shuffle(V.begin(), V.end());
int nn = 0;
for (int i, x = 0; x <= m; x++){
i = V[x];
mak (i);
nn = max (nn, a[i] + b[i]);
if (nn > 26)
break;
}
m = nn;
vector < int > ans = solve (0, n-1, 1, m);
for (int x : ans){
mak (x);
if (a[x] + b[x] == 0)
return x;
}
}
Compilation message
prize.cpp:21:1: warning: "/*" within comment [-Wcomment]
21 | /*
|
prize.cpp: In function 'std::vector<int> solve(int, int, int, int)':
prize.cpp:58:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
58 | int mid = l + r >> 1;
| ~~^~~
prize.cpp:67:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
67 | int ri = (l+r>>1)+1;
| ~^~
prize.cpp: In function 'int find_best(int)':
prize.cpp:83:20: warning: control reaches end of non-void function [-Wreturn-type]
83 | vector < int > V;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
3312 KB |
Output is correct |
2 |
Correct |
80 ms |
3432 KB |
Output is correct |
3 |
Correct |
80 ms |
3408 KB |
Output is correct |
4 |
Correct |
79 ms |
3308 KB |
Output is correct |
5 |
Correct |
80 ms |
3436 KB |
Output is correct |
6 |
Correct |
80 ms |
3304 KB |
Output is correct |
7 |
Correct |
80 ms |
3436 KB |
Output is correct |
8 |
Correct |
81 ms |
3436 KB |
Output is correct |
9 |
Correct |
80 ms |
3436 KB |
Output is correct |
10 |
Correct |
81 ms |
3344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
3432 KB |
Output is correct |
2 |
Correct |
80 ms |
3436 KB |
Output is correct |
3 |
Correct |
80 ms |
3436 KB |
Output is correct |
4 |
Correct |
79 ms |
3308 KB |
Output is correct |
5 |
Correct |
77 ms |
3412 KB |
Output is correct |
6 |
Correct |
78 ms |
3480 KB |
Output is correct |
7 |
Correct |
78 ms |
3412 KB |
Output is correct |
8 |
Correct |
80 ms |
3432 KB |
Output is correct |
9 |
Correct |
80 ms |
3304 KB |
Output is correct |
10 |
Correct |
79 ms |
3412 KB |
Output is correct |
11 |
Correct |
79 ms |
2668 KB |
Output is correct |
12 |
Correct |
80 ms |
2664 KB |
Output is correct |
13 |
Correct |
78 ms |
2664 KB |
Output is correct |
14 |
Correct |
17 ms |
768 KB |
Output is correct |
15 |
Correct |
108 ms |
3652 KB |
Output is correct |
16 |
Correct |
106 ms |
3564 KB |
Output is correct |
17 |
Correct |
117 ms |
3564 KB |
Output is correct |
18 |
Correct |
120 ms |
3692 KB |
Output is correct |
19 |
Correct |
99 ms |
3612 KB |
Output is correct |
20 |
Correct |
63 ms |
2032 KB |
Output is correct |
21 |
Correct |
118 ms |
3568 KB |
Output is correct |
22 |
Correct |
104 ms |
3568 KB |
Output is correct |
23 |
Correct |
79 ms |
3432 KB |
Output is correct |
24 |
Correct |
80 ms |
2320 KB |
Output is correct |
25 |
Correct |
113 ms |
3560 KB |
Output is correct |
26 |
Correct |
95 ms |
3652 KB |
Output is correct |
27 |
Correct |
82 ms |
3432 KB |
Output is correct |
28 |
Correct |
112 ms |
3608 KB |
Output is correct |
29 |
Correct |
107 ms |
3564 KB |
Output is correct |
30 |
Correct |
114 ms |
3732 KB |
Output is correct |
31 |
Correct |
119 ms |
3564 KB |
Output is correct |
32 |
Correct |
79 ms |
2592 KB |
Output is correct |
33 |
Correct |
2 ms |
384 KB |
Output is correct |
34 |
Correct |
108 ms |
3564 KB |
Output is correct |
35 |
Correct |
85 ms |
3432 KB |
Output is correct |
36 |
Correct |
119 ms |
3560 KB |
Output is correct |
37 |
Correct |
78 ms |
2284 KB |
Output is correct |
38 |
Correct |
80 ms |
3436 KB |
Output is correct |
39 |
Correct |
116 ms |
3608 KB |
Output is correct |
40 |
Correct |
94 ms |
3768 KB |
Output is correct |
41 |
Correct |
111 ms |
3612 KB |
Output is correct |
42 |
Correct |
98 ms |
3708 KB |
Output is correct |
43 |
Correct |
116 ms |
3688 KB |
Output is correct |
44 |
Correct |
116 ms |
3560 KB |
Output is correct |
45 |
Correct |
102 ms |
3564 KB |
Output is correct |
46 |
Correct |
120 ms |
3688 KB |
Output is correct |
47 |
Correct |
105 ms |
3580 KB |
Output is correct |
48 |
Correct |
109 ms |
3560 KB |
Output is correct |
49 |
Correct |
115 ms |
3560 KB |
Output is correct |
50 |
Correct |
113 ms |
3688 KB |
Output is correct |
51 |
Correct |
110 ms |
3564 KB |
Output is correct |
52 |
Correct |
108 ms |
3564 KB |
Output is correct |
53 |
Correct |
80 ms |
3432 KB |
Output is correct |
54 |
Correct |
109 ms |
3560 KB |
Output is correct |
55 |
Correct |
111 ms |
3564 KB |
Output is correct |
56 |
Correct |
122 ms |
3560 KB |
Output is correct |
57 |
Correct |
127 ms |
3564 KB |
Output is correct |
58 |
Correct |
128 ms |
3564 KB |
Output is correct |
59 |
Correct |
127 ms |
3692 KB |
Output is correct |
60 |
Correct |
130 ms |
3688 KB |
Output is correct |
61 |
Correct |
79 ms |
3480 KB |
Output is correct |
62 |
Correct |
80 ms |
3432 KB |
Output is correct |
63 |
Correct |
81 ms |
3436 KB |
Output is correct |
64 |
Correct |
81 ms |
3436 KB |
Output is correct |
65 |
Correct |
74 ms |
1528 KB |
Output is correct |
66 |
Correct |
76 ms |
1528 KB |
Output is correct |
67 |
Correct |
77 ms |
1528 KB |
Output is correct |
68 |
Correct |
77 ms |
1528 KB |
Output is correct |
69 |
Correct |
78 ms |
1528 KB |
Output is correct |
70 |
Correct |
75 ms |
1520 KB |
Output is correct |
71 |
Correct |
130 ms |
3564 KB |
Output is correct |
72 |
Correct |
81 ms |
2664 KB |
Output is correct |
73 |
Correct |
125 ms |
3560 KB |
Output is correct |
74 |
Correct |
120 ms |
3632 KB |
Output is correct |
75 |
Correct |
82 ms |
3436 KB |
Output is correct |
76 |
Correct |
99 ms |
3696 KB |
Output is correct |
77 |
Correct |
117 ms |
3564 KB |
Output is correct |
78 |
Correct |
78 ms |
2668 KB |
Output is correct |
79 |
Correct |
99 ms |
3820 KB |
Output is correct |
80 |
Correct |
112 ms |
3564 KB |
Output is correct |
81 |
Correct |
115 ms |
3624 KB |
Output is correct |
82 |
Correct |
112 ms |
3688 KB |
Output is correct |
83 |
Correct |
82 ms |
3436 KB |
Output is correct |
84 |
Correct |
107 ms |
3736 KB |
Output is correct |
85 |
Correct |
113 ms |
3600 KB |
Output is correct |
86 |
Correct |
91 ms |
3052 KB |
Output is correct |
87 |
Correct |
75 ms |
1904 KB |
Output is correct |
88 |
Correct |
82 ms |
3184 KB |
Output is correct |
89 |
Correct |
86 ms |
3048 KB |
Output is correct |
90 |
Correct |
82 ms |
3432 KB |
Output is correct |
91 |
Correct |
88 ms |
3092 KB |
Output is correct |
92 |
Correct |
87 ms |
3100 KB |
Output is correct |
93 |
Correct |
119 ms |
3568 KB |
Output is correct |
94 |
Correct |
113 ms |
3692 KB |
Output is correct |
95 |
Correct |
110 ms |
3564 KB |
Output is correct |
96 |
Correct |
105 ms |
3564 KB |
Output is correct |
97 |
Correct |
108 ms |
3544 KB |
Output is correct |