이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
#include <bits/stdc++.h>
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
using namespace std;
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef unsigned long long ull;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 333;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e3 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;
using namespace std;
unordered_map < int, int > res[N][N];
int cnt[N], root;
set < int > s[N];
vi g[N];
int ask (int x, int y, int z) {
vi v;
v.pb(x);
v.pb(y);
v.pb(z);
sort(all(v));
x = v[0];
y = v[1];
z = v[2];
if (res[x][y].count(z))
return res[x][y][z];
return res[x][y][z] = Query(x, y, z);
}
bool cmp (int x, int y) {
return ask(root, x, y) == x;
}
void solve (int Root, vi v) {
root = Root;
int x = v[rand() % sz(v)];
// cerr << x << endl;
vi path;
path.pb(x);
unordered_map < int, vi > tmp;
for (auto y : v) {
if (x == y)
continue;
int res = ask(root, x, y);
if (res == y)
path.pb(y);
else
tmp[res].pb(y);
}
sort(all(path), cmp);
for (int i = 0; i < sz(path); ++i) {
int a = path[i], b = !i ? root : path[i - 1];
Bridge(min(a, b), max(a, b));
}
for (auto y : tmp)
solve(y.f, y.s);
}
void Solve(int n) {
srand(time(0));
root = rand() % n;
vi tmp;
for (int i = 0; i < n; ++i)
if (i != root)
tmp.pb(i);
solve(root, tmp);
}
# | 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... |