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>
#define pb push_back
// Query(a , b , c);
// Bridge(x , y)
using namespace std;
int root,fix[2005];
vector<int>g[2005];
bool xD(int a,int b){
int p = Query(root , a , b);
if(a == p)return 1;
return 0;
}
void bridge(int x,int y){
if(y < x)swap(x , y);
Bridge(x , y);
}
void rec(vector<int>v){
int n = (int)v.size();
if(n == 1)return;
random_shuffle(v.begin() , v.end());
root = v[0];
int x = v[1];
if(n == 2){
bridge(root , x);
return;
}
vector<int>t;
for(int i=0; i<n; i++){
fix[v[i]] = 0;
g[v[i]].clear();
}
g[x].pb(x);
g[root].pb(root);
fix[root] = 1;
for(int i=2; i<n; i++){
int k = Query(root , x , v[i]);
if(!fix[k])t.pb(k);
g[k].pb(v[i]);
fix[k] = 1;
}
if(!fix[x])t.pb(x);
sort(t.begin() , t.end() , xD);
bridge(root , t[0]);
for(int i=1; i<t.size(); i++)bridge(t[i - 1] , t[i]);
rec(g[root]);
for(int i=0; i<t.size(); i++)
rec(g[t[i]]);
}
void Solve(int N){
vector<int>gg;
for(int i=0; i<N; i++)
gg.pb(i);
rec(gg);
}
Compilation message (stderr)
meetings.cpp: In function 'void rec(std::vector<int>)':
meetings.cpp:46:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1; i<t.size(); i++)bridge(t[i - 1] , t[i]);
~^~~~~~~~~
meetings.cpp:48:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<t.size(); i++)
~^~~~~~~~~
# | 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... |