# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
400179 | Victor | Meetings (JOI19_meetings) | C++17 | 1002 ms | 960 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 "meetings.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = b - 1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define umap unordered_map
#define uset unordered_set
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
const int INF = 1000000007;
struct edge {
int u, v;
};
vii EL;
vi children[2001];
void solve(int u) {
vi nodes = children[u];
children[u].clear();
int v = nodes[random() % sz(nodes)];
vi path;
path.pb(u);
rep(i, 0, sz(nodes)) {
int cur = nodes[i];
if (cur == v) continue;
int meet = Query(u, v, cur);
if (meet == cur) {
int lo = 1, hi = sz(path);
while (lo < hi) {
int mid = (hi + lo) >> 1;
meet = Query(u, cur, path[mid]);
if (meet == cur)
hi = mid;
else
lo = mid + 1;
}
path.insert(path.begin() + lo, cur);
} else
children[meet].pb(cur);
}
path.pb(v);
rep(i, 0, sz(path) - 1) EL.emplace_back(min(path[i], path[i + 1]), max(path[i], path[i + 1]));
rep(i, 0, sz(path)) if (sz(children[path[i]])) solve(path[i]);
}
void Solve(int N) {
fill(children, children + 2001, vi());
rep(i, 1, N) children[0].pb(i);
solve(0);
sort(all(EL));
trav(edg, EL) Bridge(edg.first,edg.second);
}
Compilation message (stderr)
# | 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... |