# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
481928 | Lam_lai_cuoc_doi | Meetings (JOI19_meetings) | C++17 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
void read(T &x)
{
x = 0;
register int c;
while ((c = getchar()) && (c > '9' || c < '0'))
;
for (; c >= '0' && c <= '9'; c = getchar())
x = x * 10 + c - '0';
}
constexpr bool typetest = 0;
constexpr int N = 2e3 + 5;
bool ck[N];
void Recursive(vector<int> &s)
{
if (s.size() < 1)
return;
if (s.size() == 2)
{
Bridge(min(s[0], s[1]), max(s[0], s[1]));
return;
}
int u = s[0], v = s[1];
vector<int> l, r, use;
for (int i = 2; i < (int)s.size(); ++i)
use.emplace_back(s[i]);
while (!use.empty())
{
if (ck[use.back()])
{
use.pop();
continue;
}
int z = Query(u, v, use.back());
if (z == u)
r.emplace_back(z);
else if (z == v)
l.emplace_back(z);
else
{
l.emplace_back(use.back());
l.emplace_back(v);
v = z;
}
}
Bridge(min(u, v), max(u, v));
for (auto i : s)
ck[i] = 0;
l.emplace_back(v);
r.emplace_back(u);
Recursive(l);
Recursive(r);
}
void Solve(int n)
{
vector<int> s;
for (int i = 1; i <= n; ++i)
s.emplace_back(i);
Recursive(s);
}