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>
#include "meetings.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;
for (int i = (int)s.size() - 1; i > 1; --i)
{
if (s[i] == u || s[i] == v)
continue;
int z = Query(u, v, s[i]);
if (z == u)
r.emplace_back(s[i]);
else if (z == v)
l.emplace_back(s[i]);
else
{
if (s[i] != z)
l.emplace_back(s[i]);
l.emplace_back(v);
v = z;
}
}
Bridge(min(u, v), max(u, v));
l.emplace_back(v);
r.emplace_back(u);
Recursive(l);
Recursive(r);
}
void Solve(int n)
{
vector<int> s;
for (int i = 0; i < n; ++i)
s.emplace_back(i);
random_shuffle(s.begin(), s.end());
Recursive(s);
}
/*
void Read()
{
}
void Solve()
{
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("xor.INP", "r"))
{
freopen("xor.inp", "r", stdin);
freopen("xor.out", "w", stdout);
}
int t(1);
if (typetest)
cin >> t;
for (int _ = 1; _ <= t; ++_)
{
// cout << "Case #" << _ << ": ";
Read();
Solve();
}
// cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
*/
Compilation message (stderr)
meetings.cpp: In function 'void read(T&)':
meetings.cpp:13:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
13 | register int c;
| ^
# | 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... |