// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
#include "meetings.h"
using namespace std;
#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())
template<class T> using V = vector<T>;
using vi = V<int>;
const int nax = 2005;
vi can[nax];
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int piv;
int cmp(int x, int y) {
// x < y
return Query(piv, x, y) == x;
}
void solve(vi A) {
if (sz(A) <= 1) return;
shuffle(begin(A), end(A), rng);
int u = A[0], v = A[1];
for(auto x : A) can[x] = {};
vi P;
can[u].pb(u); can[v].pb(v);
for(auto x : A) {
if (x == u || x == v) continue;
int r = Query(x, u, v);
if (r == x) P.pb(r);
can[r].pb(x);
}
piv = u;
stable_sort(begin(P), end(P), cmp);
P.insert(begin(P), u); P.pb(v);
for(int i = 1; i < sz(P); i++) Bridge(min(P[i], P[i-1]), max(P[i], P[i-1]));
for(auto i : P) solve(can[i]);
}
void Solve(int N) {
vi A(N); iota(begin(A), end(A), 0);
solve(A);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
596 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
596 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
596 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
344 KB |
Output is correct |
27 |
Correct |
3 ms |
344 KB |
Output is correct |
28 |
Correct |
3 ms |
344 KB |
Output is correct |
29 |
Correct |
3 ms |
572 KB |
Output is correct |
30 |
Correct |
3 ms |
344 KB |
Output is correct |
31 |
Correct |
3 ms |
576 KB |
Output is correct |
32 |
Correct |
3 ms |
344 KB |
Output is correct |
33 |
Correct |
5 ms |
344 KB |
Output is correct |
34 |
Correct |
6 ms |
600 KB |
Output is correct |
35 |
Correct |
5 ms |
564 KB |
Output is correct |
36 |
Correct |
3 ms |
568 KB |
Output is correct |
37 |
Correct |
4 ms |
600 KB |
Output is correct |
38 |
Correct |
5 ms |
600 KB |
Output is correct |
39 |
Correct |
5 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
189 ms |
732 KB |
Output is correct |
2 |
Correct |
196 ms |
840 KB |
Output is correct |
3 |
Correct |
166 ms |
1272 KB |
Output is correct |
4 |
Correct |
158 ms |
848 KB |
Output is correct |
5 |
Correct |
151 ms |
708 KB |
Output is correct |
6 |
Correct |
177 ms |
816 KB |
Output is correct |
7 |
Correct |
259 ms |
820 KB |
Output is correct |
8 |
Correct |
260 ms |
848 KB |
Output is correct |
9 |
Correct |
255 ms |
1116 KB |
Output is correct |
10 |
Correct |
259 ms |
732 KB |
Output is correct |
11 |
Correct |
289 ms |
892 KB |
Output is correct |
12 |
Correct |
230 ms |
848 KB |
Output is correct |
13 |
Correct |
106 ms |
848 KB |
Output is correct |
14 |
Correct |
147 ms |
848 KB |
Output is correct |
15 |
Correct |
186 ms |
720 KB |
Output is correct |
16 |
Correct |
165 ms |
796 KB |
Output is correct |
17 |
Correct |
259 ms |
744 KB |
Output is correct |
18 |
Correct |
143 ms |
844 KB |
Output is correct |
19 |
Correct |
183 ms |
740 KB |
Output is correct |
20 |
Correct |
166 ms |
740 KB |
Output is correct |
21 |
Correct |
184 ms |
848 KB |
Output is correct |
22 |
Correct |
177 ms |
892 KB |
Output is correct |
23 |
Correct |
186 ms |
748 KB |
Output is correct |
24 |
Correct |
156 ms |
736 KB |
Output is correct |
25 |
Correct |
186 ms |
816 KB |
Output is correct |
26 |
Correct |
158 ms |
804 KB |
Output is correct |
27 |
Correct |
203 ms |
864 KB |
Output is correct |
28 |
Correct |
313 ms |
1120 KB |
Output is correct |
29 |
Correct |
238 ms |
852 KB |
Output is correct |
30 |
Correct |
261 ms |
1044 KB |
Output is correct |
31 |
Correct |
271 ms |
728 KB |
Output is correct |
32 |
Correct |
506 ms |
1660 KB |
Output is correct |
33 |
Correct |
498 ms |
976 KB |
Output is correct |
34 |
Correct |
4 ms |
344 KB |
Output is correct |
35 |
Correct |
3 ms |
600 KB |
Output is correct |
36 |
Correct |
4 ms |
572 KB |
Output is correct |
37 |
Correct |
3 ms |
344 KB |
Output is correct |
38 |
Correct |
3 ms |
344 KB |
Output is correct |
39 |
Correct |
3 ms |
344 KB |
Output is correct |
40 |
Correct |
4 ms |
584 KB |
Output is correct |
41 |
Correct |
7 ms |
600 KB |
Output is correct |
42 |
Correct |
5 ms |
580 KB |
Output is correct |
43 |
Correct |
3 ms |
344 KB |
Output is correct |
44 |
Correct |
5 ms |
592 KB |
Output is correct |
45 |
Correct |
7 ms |
600 KB |
Output is correct |
46 |
Correct |
8 ms |
600 KB |
Output is correct |
47 |
Correct |
0 ms |
344 KB |
Output is correct |
48 |
Correct |
0 ms |
344 KB |
Output is correct |
49 |
Correct |
0 ms |
344 KB |
Output is correct |
50 |
Correct |
1 ms |
344 KB |
Output is correct |
51 |
Correct |
0 ms |
344 KB |
Output is correct |
52 |
Correct |
0 ms |
344 KB |
Output is correct |
53 |
Correct |
1 ms |
344 KB |
Output is correct |
54 |
Correct |
0 ms |
344 KB |
Output is correct |
55 |
Correct |
0 ms |
344 KB |
Output is correct |
56 |
Correct |
1 ms |
344 KB |
Output is correct |
57 |
Correct |
0 ms |
344 KB |
Output is correct |
58 |
Correct |
0 ms |
344 KB |
Output is correct |
59 |
Correct |
0 ms |
344 KB |
Output is correct |
60 |
Correct |
0 ms |
344 KB |
Output is correct |
61 |
Correct |
0 ms |
344 KB |
Output is correct |
62 |
Correct |
0 ms |
344 KB |
Output is correct |
63 |
Correct |
0 ms |
344 KB |
Output is correct |
64 |
Correct |
0 ms |
344 KB |
Output is correct |
65 |
Correct |
0 ms |
344 KB |
Output is correct |
66 |
Correct |
0 ms |
344 KB |
Output is correct |
67 |
Correct |
0 ms |
344 KB |
Output is correct |
68 |
Correct |
0 ms |
344 KB |
Output is correct |
69 |
Correct |
0 ms |
344 KB |
Output is correct |
70 |
Correct |
0 ms |
344 KB |
Output is correct |
71 |
Correct |
0 ms |
344 KB |
Output is correct |
72 |
Correct |
0 ms |
344 KB |
Output is correct |