This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
map<tuple<int, int, int>, int> Bfq;
int query(int a, int b, int c) {
if(a > b) return query(b, a, c);
if(a > c) return query(c, b, a);
if(b > c) return query(a, c, b);
if(Bfq.count({a, b, c})) return Bfq[{a, b, c}];
int v = Query(a, b, c);
Bfq[{a, b, c}] = v;
return v;
}
#define pb push_back
void solve(int root, const vi& U, mt19937 rng) {
map<int, vi> Altii;
vi lant;
int pivot = U[uniform_int_distribution<int>(0, U.size() - 1)(rng)];
lant.pb(pivot);
for(auto it : U) {
if(it == pivot) continue;
int v = query(root, it, pivot);
if(v == it) lant.pb(v);
else Altii[v].pb(it);
}
sort(lant.begin(), lant.end(), [&](auto a, auto b) {
return query(root, a, b) == a;
});
Bridge(root, lant[0]);
for(int i = 0; i < lant.size() - 1; ++i)
Bridge(lant[i], lant[i+1]);
for(auto &[rn, Un] : Altii)
solve(rn, Un, rng);
}
void Solve(int N) {
Bfq.clear();
mt19937 rng(2);
vi E;
for(int i = 1; i < N; ++i) E.pb(i);
solve(0, E, rng);
}
Compilation message (stderr)
meetings.cpp: In function 'void solve(int, const vi&, std::mt19937)':
meetings.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int i = 0; i < lant.size() - 1; ++i)
| ~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |