#include "meetings.h"
#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
#define int LL
using namespace std;
using LL = long long;
using pii = pair<int, int>;
const int MAXN = 2010;
// struct DSU {
// int p[MAXN];
// void init() {
// memset(p, -1, sizeof(p));
// }
// int find(int n) {
// if(p[n] < 0) return n;
// return p[n] = find(p[n]);
// }
// void uni(int a, int b) {
// a = find(a); b = find(b);
// if(a != b) p[b] = a;
// }
// } dsu;
mt19937_64 rng(48763);
vector<pii> edges;
void solve(vector<int> &ids) {
// for(auto &i:ids) cerr << i << " ";
// cerr << "\n";
if(sz(ids) == 1) return;
int rt = rng() % sz(ids);
int p1 = rng() % sz(ids);
while(p1 == rt) p1 = rng() % sz(ids);
rt = ids[rt]; p1 = ids[p1];
vector<int> a(1, p1), b(1, rt);
for(auto &i:ids) if(i != rt && i != p1) {
auto res = Query(rt, p1, i);
if(res != rt) {
a.eb(i);
p1 = res;
} else {
b.eb(i);
}
}
edges.eb(rt, p1);
solve(a);
solve(b);
}
void Solve(int32_t n) {
vector<int> ids(n);
For(i, 0, n - 1) ids[i] = i;
solve(ids);
for(auto &p:edges) {
if(p.F > p.S) swap(p.F, p.S);
Bridge(p.F, p.S);
}
}
// int x = Query(0, 1, 2);
// for (int u = 0; u < N - 1; ++u) {
// Bridge(u, u + 1);
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Incorrect |
0 ms |
336 KB |
Wrong Answer [4] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Incorrect |
0 ms |
336 KB |
Wrong Answer [4] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Incorrect |
0 ms |
336 KB |
Wrong Answer [4] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1280 ms |
996 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |