#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
mt19937 rng(0x14004);
int randint(int lb, int ub){ return uniform_int_distribution<int>(lb, ub)(rng); }
void bridge(int x, int y){ Bridge(min(x, y), max(x, y)); }
void dfs(vector<int> v){
if(v.size() == 1) return;
if(v.size() == 2){
bridge(v[0], v[1]);
return;
}
map<int, int> mp;
for(int i=0; i<11; i++){
set<int> s;
while(s.size() < 3){
s.insert(v[randint(0, v.size() - 1)]);
}
int x = *s.begin();
int y = *next(s.begin());
int z = *next(next(s.begin()));
int q = Query(x, y, z);
mp[q]++;
}
pi ret(-1, -1);
for(auto &i : mp){
ret = max(ret, pi(i.second, i.first));
}
int c = ret.second;
vector<vector<int>> anclist;
for(auto &i : v){
if(i == c) continue;
bool found = 0;
for(auto &j : anclist){
if(find(j.begin(), j.end(), i) != j.end()){
found = 1;
break;
}
}
if(found) continue;
for(auto &j : anclist){
int x = Query(i, j[0], c);
if(x == c) continue;
j.push_back(i);
if(find(j.begin(), j.end(), x) == j.end()) j.push_back(x);
swap(j[0], *find(j.begin(), j.end(), x));
found = 1;
break;
}
if(!found){
anclist.push_back({i});
}
}
for(auto &i : anclist){
bridge(c, i[0]);
dfs(i);
}
}
void Solve(int N) {
vector<int> v(N);
iota(v.begin(), v.end(), 0);
dfs(v);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
248 KB |
Output is correct |
7 |
Correct |
2 ms |
248 KB |
Output is correct |
8 |
Correct |
2 ms |
248 KB |
Output is correct |
9 |
Correct |
2 ms |
248 KB |
Output is correct |
10 |
Correct |
2 ms |
248 KB |
Output is correct |
11 |
Correct |
2 ms |
248 KB |
Output is correct |
12 |
Correct |
2 ms |
248 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
248 KB |
Output is correct |
7 |
Correct |
2 ms |
248 KB |
Output is correct |
8 |
Correct |
2 ms |
248 KB |
Output is correct |
9 |
Correct |
2 ms |
248 KB |
Output is correct |
10 |
Correct |
2 ms |
248 KB |
Output is correct |
11 |
Correct |
2 ms |
248 KB |
Output is correct |
12 |
Correct |
2 ms |
248 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
248 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
404 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
252 KB |
Output is correct |
24 |
Correct |
2 ms |
248 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
248 KB |
Output is correct |
7 |
Correct |
2 ms |
248 KB |
Output is correct |
8 |
Correct |
2 ms |
248 KB |
Output is correct |
9 |
Correct |
2 ms |
248 KB |
Output is correct |
10 |
Correct |
2 ms |
248 KB |
Output is correct |
11 |
Correct |
2 ms |
248 KB |
Output is correct |
12 |
Correct |
2 ms |
248 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
248 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
404 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
252 KB |
Output is correct |
24 |
Correct |
2 ms |
248 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
252 KB |
Output is correct |
27 |
Correct |
7 ms |
380 KB |
Output is correct |
28 |
Correct |
8 ms |
376 KB |
Output is correct |
29 |
Correct |
8 ms |
376 KB |
Output is correct |
30 |
Correct |
7 ms |
376 KB |
Output is correct |
31 |
Correct |
9 ms |
376 KB |
Output is correct |
32 |
Correct |
7 ms |
376 KB |
Output is correct |
33 |
Correct |
8 ms |
376 KB |
Output is correct |
34 |
Correct |
10 ms |
376 KB |
Output is correct |
35 |
Correct |
9 ms |
376 KB |
Output is correct |
36 |
Correct |
9 ms |
376 KB |
Output is correct |
37 |
Correct |
15 ms |
376 KB |
Output is correct |
38 |
Correct |
15 ms |
376 KB |
Output is correct |
39 |
Correct |
18 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
703 ms |
760 KB |
Output is correct |
2 |
Correct |
779 ms |
808 KB |
Output is correct |
3 |
Correct |
705 ms |
892 KB |
Output is correct |
4 |
Correct |
732 ms |
760 KB |
Output is correct |
5 |
Correct |
595 ms |
632 KB |
Output is correct |
6 |
Correct |
416 ms |
820 KB |
Output is correct |
7 |
Correct |
323 ms |
632 KB |
Output is correct |
8 |
Correct |
366 ms |
632 KB |
Output is correct |
9 |
Correct |
419 ms |
760 KB |
Output is correct |
10 |
Correct |
361 ms |
632 KB |
Output is correct |
11 |
Correct |
411 ms |
632 KB |
Output is correct |
12 |
Correct |
934 ms |
888 KB |
Output is correct |
13 |
Correct |
671 ms |
808 KB |
Output is correct |
14 |
Correct |
450 ms |
652 KB |
Output is correct |
15 |
Correct |
442 ms |
760 KB |
Output is correct |
16 |
Correct |
436 ms |
760 KB |
Output is correct |
17 |
Correct |
348 ms |
808 KB |
Output is correct |
18 |
Correct |
495 ms |
760 KB |
Output is correct |
19 |
Correct |
494 ms |
760 KB |
Output is correct |
20 |
Correct |
450 ms |
780 KB |
Output is correct |
21 |
Correct |
473 ms |
644 KB |
Output is correct |
22 |
Correct |
488 ms |
840 KB |
Output is correct |
23 |
Correct |
511 ms |
856 KB |
Output is correct |
24 |
Correct |
449 ms |
592 KB |
Output is correct |
25 |
Correct |
497 ms |
772 KB |
Output is correct |
26 |
Correct |
445 ms |
632 KB |
Output is correct |
27 |
Correct |
1083 ms |
820 KB |
Output is correct |
28 |
Correct |
411 ms |
700 KB |
Output is correct |
29 |
Correct |
374 ms |
760 KB |
Output is correct |
30 |
Correct |
363 ms |
632 KB |
Output is correct |
31 |
Correct |
373 ms |
760 KB |
Output is correct |
32 |
Correct |
1690 ms |
936 KB |
Output is correct |
33 |
Correct |
1359 ms |
900 KB |
Output is correct |
34 |
Correct |
7 ms |
392 KB |
Output is correct |
35 |
Correct |
8 ms |
296 KB |
Output is correct |
36 |
Correct |
8 ms |
404 KB |
Output is correct |
37 |
Correct |
8 ms |
376 KB |
Output is correct |
38 |
Correct |
9 ms |
376 KB |
Output is correct |
39 |
Correct |
7 ms |
376 KB |
Output is correct |
40 |
Correct |
8 ms |
472 KB |
Output is correct |
41 |
Correct |
9 ms |
376 KB |
Output is correct |
42 |
Correct |
9 ms |
376 KB |
Output is correct |
43 |
Correct |
9 ms |
376 KB |
Output is correct |
44 |
Correct |
15 ms |
376 KB |
Output is correct |
45 |
Correct |
14 ms |
376 KB |
Output is correct |
46 |
Correct |
18 ms |
504 KB |
Output is correct |
47 |
Correct |
2 ms |
248 KB |
Output is correct |
48 |
Correct |
2 ms |
376 KB |
Output is correct |
49 |
Correct |
2 ms |
248 KB |
Output is correct |
50 |
Correct |
2 ms |
376 KB |
Output is correct |
51 |
Correct |
2 ms |
248 KB |
Output is correct |
52 |
Correct |
2 ms |
376 KB |
Output is correct |
53 |
Correct |
2 ms |
376 KB |
Output is correct |
54 |
Correct |
2 ms |
376 KB |
Output is correct |
55 |
Correct |
2 ms |
296 KB |
Output is correct |
56 |
Correct |
2 ms |
376 KB |
Output is correct |
57 |
Correct |
2 ms |
376 KB |
Output is correct |
58 |
Correct |
2 ms |
376 KB |
Output is correct |
59 |
Correct |
2 ms |
376 KB |
Output is correct |
60 |
Correct |
2 ms |
376 KB |
Output is correct |
61 |
Correct |
2 ms |
376 KB |
Output is correct |
62 |
Correct |
2 ms |
376 KB |
Output is correct |
63 |
Correct |
2 ms |
248 KB |
Output is correct |
64 |
Correct |
2 ms |
376 KB |
Output is correct |
65 |
Correct |
2 ms |
376 KB |
Output is correct |
66 |
Correct |
2 ms |
376 KB |
Output is correct |
67 |
Correct |
2 ms |
248 KB |
Output is correct |
68 |
Correct |
2 ms |
248 KB |
Output is correct |
69 |
Correct |
2 ms |
248 KB |
Output is correct |
70 |
Correct |
2 ms |
376 KB |
Output is correct |
71 |
Correct |
2 ms |
248 KB |
Output is correct |
72 |
Correct |
2 ms |
252 KB |
Output is correct |