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 X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;
const int INF=0x3f3f3f3f;
int n;
void rek(vector <int> v) {
if (v.size()==1) return;
int uk=0, siz=v.size();
vector <int> nv[18];
int koji[18];
int cent=v[rand()%(int)v.size()];
#if DEBUG
printf("cent: %d\n", cent);
for (int x:v) printf("%d ", x);
printf("\n");
#endif // DEBUG
for (int x:v) {
if (x==cent) continue;
int fl=0;
for (int i=0; i<uk; ++i) {
int y=Query(cent, koji[i], x);
if (y==cent) continue;
nv[i].pb(x);
fl=1;
if (y==x) koji[i]=x;
break;
}
if (!fl) {
nv[uk].pb(x);
koji[uk++]=x;
}
}
for (int i=0; i<uk; ++i) Bridge(min(cent, koji[i]), max(koji[i], cent));
for (int i=0; i<uk; ++i) rek(nv[i]);
}
void Solve(int nn) {
n=nn;
srand(time(0));
vector <int> poc;
for (int i=0; i<n; ++i) poc.pb(i);
random_shuffle(poc.begin(), poc.end());
rek(poc);
}
/*
5
0 1
0 2
1 3
1 4
*/
Compilation message (stderr)
meetings.cpp: In function 'void rek(std::vector<int>)':
meetings.cpp:22:15: warning: unused variable 'siz' [-Wunused-variable]
22 | int uk=0, siz=v.size();
| ^~~
# | 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... |