#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3+5;
mt19937 rng(time(NULL));
void connect(int a, int b) {
if(a > b) swap(a, b);
Bridge(a, b);
}
vector<int> sub[N];
void solve(vector<int> vec) {
if(vec.size() < 2) return;
for(int x : vec) sub[x].clear();
shuffle(vec.begin(), vec.end(), rng);
int a = vec[0], b = vec[1];
vector<int> path;
for(int i = 2; i < vec.size(); i++) {
int now = Query(a, b, vec[i]);
sub[now].emplace_back(vec[i]);
if(now == vec[i]) path.emplace_back(now);
}
sub[a].emplace_back(a), sub[b].emplace_back(b);
sort(path.begin(), path.end(), [&](int x, int y) {
return Query(x, y, b) == y;
});
path.insert(path.begin(), a), path.emplace_back(b);
for(int i = 0; i < path.size() - 1; i++)
connect(path[i], path[i + 1]);
for(int x : path) solve(sub[x]);
}
void Solve(int n) {
vector<int> vec;
for(int i = 0; i < n; i++) vec.emplace_back(i);
solve(vec);
}
Compilation message
meetings.cpp: In function 'void solve(std::vector<int>)':
meetings.cpp:24:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 2; i < vec.size(); i++) {
~~^~~~~~~~~~~~
meetings.cpp:34:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < path.size() - 1; i++)
~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
4 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
4 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
404 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
512 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
4 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
404 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
512 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
9 ms |
512 KB |
Output is correct |
28 |
Correct |
9 ms |
512 KB |
Output is correct |
29 |
Correct |
10 ms |
512 KB |
Output is correct |
30 |
Correct |
10 ms |
512 KB |
Output is correct |
31 |
Correct |
9 ms |
512 KB |
Output is correct |
32 |
Correct |
10 ms |
512 KB |
Output is correct |
33 |
Correct |
14 ms |
512 KB |
Output is correct |
34 |
Correct |
13 ms |
512 KB |
Output is correct |
35 |
Correct |
14 ms |
512 KB |
Output is correct |
36 |
Correct |
13 ms |
496 KB |
Output is correct |
37 |
Correct |
14 ms |
512 KB |
Output is correct |
38 |
Correct |
14 ms |
512 KB |
Output is correct |
39 |
Correct |
23 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
392 ms |
1016 KB |
Output is correct |
2 |
Correct |
441 ms |
764 KB |
Output is correct |
3 |
Correct |
464 ms |
888 KB |
Output is correct |
4 |
Correct |
437 ms |
888 KB |
Output is correct |
5 |
Correct |
396 ms |
760 KB |
Output is correct |
6 |
Correct |
383 ms |
736 KB |
Output is correct |
7 |
Correct |
422 ms |
760 KB |
Output is correct |
8 |
Correct |
458 ms |
888 KB |
Output is correct |
9 |
Correct |
426 ms |
760 KB |
Output is correct |
10 |
Correct |
398 ms |
888 KB |
Output is correct |
11 |
Correct |
481 ms |
760 KB |
Output is correct |
12 |
Correct |
468 ms |
892 KB |
Output is correct |
13 |
Correct |
292 ms |
760 KB |
Output is correct |
14 |
Correct |
310 ms |
888 KB |
Output is correct |
15 |
Correct |
337 ms |
760 KB |
Output is correct |
16 |
Correct |
300 ms |
1088 KB |
Output is correct |
17 |
Correct |
449 ms |
760 KB |
Output is correct |
18 |
Correct |
299 ms |
1144 KB |
Output is correct |
19 |
Correct |
314 ms |
760 KB |
Output is correct |
20 |
Correct |
465 ms |
924 KB |
Output is correct |
21 |
Correct |
325 ms |
760 KB |
Output is correct |
22 |
Correct |
415 ms |
912 KB |
Output is correct |
23 |
Correct |
403 ms |
764 KB |
Output is correct |
24 |
Correct |
463 ms |
928 KB |
Output is correct |
25 |
Correct |
524 ms |
888 KB |
Output is correct |
26 |
Correct |
359 ms |
760 KB |
Output is correct |
27 |
Correct |
423 ms |
888 KB |
Output is correct |
28 |
Correct |
454 ms |
888 KB |
Output is correct |
29 |
Correct |
408 ms |
760 KB |
Output is correct |
30 |
Correct |
389 ms |
760 KB |
Output is correct |
31 |
Correct |
436 ms |
888 KB |
Output is correct |
32 |
Correct |
916 ms |
1020 KB |
Output is correct |
33 |
Correct |
728 ms |
1144 KB |
Output is correct |
34 |
Correct |
9 ms |
512 KB |
Output is correct |
35 |
Correct |
11 ms |
512 KB |
Output is correct |
36 |
Correct |
10 ms |
512 KB |
Output is correct |
37 |
Correct |
10 ms |
512 KB |
Output is correct |
38 |
Correct |
8 ms |
512 KB |
Output is correct |
39 |
Correct |
11 ms |
512 KB |
Output is correct |
40 |
Correct |
13 ms |
512 KB |
Output is correct |
41 |
Correct |
13 ms |
512 KB |
Output is correct |
42 |
Correct |
14 ms |
640 KB |
Output is correct |
43 |
Correct |
8 ms |
512 KB |
Output is correct |
44 |
Correct |
17 ms |
512 KB |
Output is correct |
45 |
Correct |
13 ms |
512 KB |
Output is correct |
46 |
Correct |
14 ms |
512 KB |
Output is correct |
47 |
Correct |
5 ms |
384 KB |
Output is correct |
48 |
Correct |
5 ms |
384 KB |
Output is correct |
49 |
Correct |
5 ms |
384 KB |
Output is correct |
50 |
Correct |
5 ms |
384 KB |
Output is correct |
51 |
Correct |
5 ms |
640 KB |
Output is correct |
52 |
Correct |
5 ms |
512 KB |
Output is correct |
53 |
Correct |
5 ms |
384 KB |
Output is correct |
54 |
Correct |
5 ms |
384 KB |
Output is correct |
55 |
Correct |
5 ms |
384 KB |
Output is correct |
56 |
Correct |
5 ms |
512 KB |
Output is correct |
57 |
Correct |
5 ms |
384 KB |
Output is correct |
58 |
Correct |
5 ms |
384 KB |
Output is correct |
59 |
Correct |
5 ms |
384 KB |
Output is correct |
60 |
Correct |
4 ms |
384 KB |
Output is correct |
61 |
Correct |
4 ms |
384 KB |
Output is correct |
62 |
Correct |
4 ms |
384 KB |
Output is correct |
63 |
Correct |
4 ms |
384 KB |
Output is correct |
64 |
Correct |
5 ms |
384 KB |
Output is correct |
65 |
Correct |
5 ms |
384 KB |
Output is correct |
66 |
Correct |
5 ms |
436 KB |
Output is correct |
67 |
Correct |
4 ms |
384 KB |
Output is correct |
68 |
Correct |
5 ms |
384 KB |
Output is correct |
69 |
Correct |
5 ms |
384 KB |
Output is correct |
70 |
Correct |
5 ms |
384 KB |
Output is correct |
71 |
Correct |
5 ms |
384 KB |
Output is correct |
72 |
Correct |
5 ms |
384 KB |
Output is correct |