#include <bits/stdc++.h>
#include "meetings.h"
using namespace std;
void Ans(int u, int v){
if (u < v) Bridge(u, v);
else Bridge(v, u);
}
void Solve(vector <int> v){
if (v.size() < 2) return;
random_shuffle(v.begin(), v.end());
int l = v[0], r = v[1];
map <int, vector <int>> m;
m[l].push_back(l);
m[r].push_back(r);
vector <int> path;
for (auto k : v){
if (k == l || k == r) continue;
int x = Query(l, r, k);
if (!m.count(x)) path.push_back(x);
m[x].push_back(k);
}
sort(path.begin(), path.end(), [&](int x, int y){
return Query(v[0], x, y) == x;
});
for (auto k : path) Ans(l, k), l = k;
Ans(l, r);
for (auto it : m) Solve(it.second);
}
void Solve(int n){
srand(time(0));
vector <int> cur(n, 0);
for (int i = 1; i < n; ++ i) cur[i] = i;
Solve(cur);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 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 |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 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 |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 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 |
0 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 |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 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 |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 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 |
0 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 |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
3 ms |
344 KB |
Output is correct |
28 |
Correct |
2 ms |
344 KB |
Output is correct |
29 |
Correct |
5 ms |
344 KB |
Output is correct |
30 |
Correct |
3 ms |
344 KB |
Output is correct |
31 |
Correct |
2 ms |
344 KB |
Output is correct |
32 |
Correct |
3 ms |
344 KB |
Output is correct |
33 |
Correct |
7 ms |
344 KB |
Output is correct |
34 |
Correct |
5 ms |
344 KB |
Output is correct |
35 |
Correct |
8 ms |
344 KB |
Output is correct |
36 |
Correct |
2 ms |
344 KB |
Output is correct |
37 |
Correct |
4 ms |
344 KB |
Output is correct |
38 |
Correct |
7 ms |
532 KB |
Output is correct |
39 |
Correct |
7 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
151 ms |
652 KB |
Output is correct |
2 |
Correct |
174 ms |
640 KB |
Output is correct |
3 |
Correct |
222 ms |
848 KB |
Output is correct |
4 |
Correct |
181 ms |
852 KB |
Output is correct |
5 |
Correct |
159 ms |
600 KB |
Output is correct |
6 |
Correct |
138 ms |
600 KB |
Output is correct |
7 |
Correct |
220 ms |
684 KB |
Output is correct |
8 |
Correct |
295 ms |
672 KB |
Output is correct |
9 |
Correct |
247 ms |
680 KB |
Output is correct |
10 |
Correct |
210 ms |
772 KB |
Output is correct |
11 |
Correct |
338 ms |
600 KB |
Output is correct |
12 |
Correct |
206 ms |
848 KB |
Output is correct |
13 |
Correct |
162 ms |
684 KB |
Output is correct |
14 |
Correct |
152 ms |
688 KB |
Output is correct |
15 |
Correct |
167 ms |
676 KB |
Output is correct |
16 |
Correct |
170 ms |
712 KB |
Output is correct |
17 |
Correct |
260 ms |
600 KB |
Output is correct |
18 |
Correct |
185 ms |
600 KB |
Output is correct |
19 |
Correct |
203 ms |
704 KB |
Output is correct |
20 |
Correct |
147 ms |
708 KB |
Output is correct |
21 |
Correct |
162 ms |
600 KB |
Output is correct |
22 |
Correct |
151 ms |
760 KB |
Output is correct |
23 |
Correct |
172 ms |
600 KB |
Output is correct |
24 |
Correct |
190 ms |
936 KB |
Output is correct |
25 |
Correct |
189 ms |
600 KB |
Output is correct |
26 |
Correct |
194 ms |
660 KB |
Output is correct |
27 |
Correct |
155 ms |
600 KB |
Output is correct |
28 |
Correct |
275 ms |
852 KB |
Output is correct |
29 |
Correct |
224 ms |
700 KB |
Output is correct |
30 |
Correct |
277 ms |
688 KB |
Output is correct |
31 |
Correct |
266 ms |
680 KB |
Output is correct |
32 |
Correct |
406 ms |
848 KB |
Output is correct |
33 |
Correct |
608 ms |
996 KB |
Output is correct |
34 |
Correct |
4 ms |
344 KB |
Output is correct |
35 |
Correct |
5 ms |
344 KB |
Output is correct |
36 |
Correct |
3 ms |
344 KB |
Output is correct |
37 |
Correct |
5 ms |
344 KB |
Output is correct |
38 |
Correct |
2 ms |
528 KB |
Output is correct |
39 |
Correct |
6 ms |
344 KB |
Output is correct |
40 |
Correct |
4 ms |
344 KB |
Output is correct |
41 |
Correct |
5 ms |
344 KB |
Output is correct |
42 |
Correct |
8 ms |
596 KB |
Output is correct |
43 |
Correct |
4 ms |
344 KB |
Output is correct |
44 |
Correct |
8 ms |
520 KB |
Output is correct |
45 |
Correct |
14 ms |
344 KB |
Output is correct |
46 |
Correct |
6 ms |
344 KB |
Output is correct |
47 |
Correct |
0 ms |
344 KB |
Output is correct |
48 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
53 |
Correct |
0 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 |
0 ms |
344 KB |
Output is correct |
57 |
Correct |
1 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 |
1 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 |
1 ms |
420 KB |
Output is correct |
68 |
Correct |
1 ms |
344 KB |
Output is correct |
69 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |