#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
void Solve(int n) {
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
auto query = [&](int u, int v, int w) -> int {
return Query(u, v, w);
};
auto bridge = [&](int u, int v) -> void {
if (u > v) swap(u, v);
Bridge(u, v);
};
auto work = [&](auto self, vector<int> dom) -> void {
if (dom.size() == 1) return;
shuffle(dom.begin(), dom.end(), rng);
int r0 = dom.back(); dom.pop_back();
int r1 = dom.back(); dom.pop_back();
vector<int> v0 = {r0};
vector<int> v1 = {r1};
map<int, vector<int>> v;
for (int u : dom) {
int get = Query(r0, r1, u);
if (get == r0) {
v0.push_back(u);
} else if (get == r1) {
v1.push_back(u);
} else {
v[get].push_back(u);
}
}
vector<int> perm;
self(self, v0);
self(self, v1);
for (auto [r, d] : v) {
self(self, d);
perm.push_back(r);
}
sort(perm.begin(), perm.end(), [&](int u, int v) {
return Query(u, v, r0) == u;
});
perm.insert(perm.begin(), r0);
perm.push_back(r1);
for (int i = 0; i + 1 < perm.size(); i++) {
bridge(perm[i], perm[i + 1]);
}
};
work(work, [&]() -> vector<int> {
vector<int> dom(n);
iota(dom.begin(), dom.end(), 0);
return dom;
}());
}
Compilation message
meetings.cpp: In lambda function:
meetings.cpp:52:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for (int i = 0; i + 1 < perm.size(); i++) {
| ~~~~~~^~~~~~~~~~~~~
meetings.cpp: In function 'void Solve(int)':
meetings.cpp:9:10: warning: variable 'query' set but not used [-Wunused-but-set-variable]
9 | auto query = [&](int u, int v, int w) -> int {
| ^~~~~
meetings.cpp: In instantiation of 'Solve(int)::<lambda(auto:23, std::vector<int>)> [with auto:23 = Solve(int)::<lambda(auto:23, std::vector<int>)>]':
meetings.cpp:62:8: required from here
meetings.cpp:52:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for (int i = 0; i + 1 < perm.size(); i++) {
| ~~~~~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 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 |
512 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 |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 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 |
512 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 |
0 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 |
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 |
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 |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 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 |
512 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 |
0 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 |
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 |
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 |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
2 ms |
344 KB |
Output is correct |
28 |
Correct |
2 ms |
344 KB |
Output is correct |
29 |
Correct |
3 ms |
344 KB |
Output is correct |
30 |
Correct |
2 ms |
344 KB |
Output is correct |
31 |
Correct |
2 ms |
344 KB |
Output is correct |
32 |
Correct |
3 ms |
512 KB |
Output is correct |
33 |
Correct |
4 ms |
344 KB |
Output is correct |
34 |
Correct |
8 ms |
552 KB |
Output is correct |
35 |
Correct |
5 ms |
344 KB |
Output is correct |
36 |
Correct |
2 ms |
344 KB |
Output is correct |
37 |
Correct |
8 ms |
532 KB |
Output is correct |
38 |
Correct |
7 ms |
344 KB |
Output is correct |
39 |
Correct |
8 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
139 ms |
660 KB |
Output is correct |
2 |
Correct |
158 ms |
600 KB |
Output is correct |
3 |
Correct |
174 ms |
672 KB |
Output is correct |
4 |
Correct |
190 ms |
852 KB |
Output is correct |
5 |
Correct |
118 ms |
600 KB |
Output is correct |
6 |
Correct |
185 ms |
600 KB |
Output is correct |
7 |
Correct |
233 ms |
688 KB |
Output is correct |
8 |
Correct |
256 ms |
656 KB |
Output is correct |
9 |
Correct |
247 ms |
696 KB |
Output is correct |
10 |
Correct |
292 ms |
600 KB |
Output is correct |
11 |
Correct |
245 ms |
600 KB |
Output is correct |
12 |
Correct |
250 ms |
1100 KB |
Output is correct |
13 |
Correct |
125 ms |
600 KB |
Output is correct |
14 |
Correct |
151 ms |
672 KB |
Output is correct |
15 |
Correct |
164 ms |
600 KB |
Output is correct |
16 |
Correct |
147 ms |
692 KB |
Output is correct |
17 |
Correct |
229 ms |
600 KB |
Output is correct |
18 |
Correct |
159 ms |
600 KB |
Output is correct |
19 |
Correct |
154 ms |
600 KB |
Output is correct |
20 |
Correct |
167 ms |
600 KB |
Output is correct |
21 |
Correct |
153 ms |
600 KB |
Output is correct |
22 |
Correct |
171 ms |
600 KB |
Output is correct |
23 |
Correct |
121 ms |
600 KB |
Output is correct |
24 |
Correct |
142 ms |
600 KB |
Output is correct |
25 |
Correct |
153 ms |
600 KB |
Output is correct |
26 |
Correct |
141 ms |
600 KB |
Output is correct |
27 |
Correct |
168 ms |
600 KB |
Output is correct |
28 |
Correct |
290 ms |
680 KB |
Output is correct |
29 |
Correct |
228 ms |
848 KB |
Output is correct |
30 |
Correct |
250 ms |
692 KB |
Output is correct |
31 |
Correct |
230 ms |
600 KB |
Output is correct |
32 |
Correct |
654 ms |
848 KB |
Output is correct |
33 |
Correct |
337 ms |
848 KB |
Output is correct |
34 |
Correct |
3 ms |
344 KB |
Output is correct |
35 |
Correct |
3 ms |
344 KB |
Output is correct |
36 |
Correct |
3 ms |
344 KB |
Output is correct |
37 |
Correct |
2 ms |
344 KB |
Output is correct |
38 |
Correct |
2 ms |
344 KB |
Output is correct |
39 |
Correct |
3 ms |
344 KB |
Output is correct |
40 |
Correct |
5 ms |
344 KB |
Output is correct |
41 |
Correct |
5 ms |
344 KB |
Output is correct |
42 |
Correct |
4 ms |
344 KB |
Output is correct |
43 |
Correct |
3 ms |
344 KB |
Output is correct |
44 |
Correct |
8 ms |
344 KB |
Output is correct |
45 |
Correct |
6 ms |
556 KB |
Output is correct |
46 |
Correct |
5 ms |
340 KB |
Output is correct |
47 |
Correct |
1 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 |
0 ms |
488 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 |
0 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 |
1 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 |