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 "icc.h"
using namespace std;
const int MAXN = 110;
int UFDS[MAXN];
int p(int n){
if(UFDS[n]==n)
return n;
else
return UFDS[n] = p(UFDS[n]);
}
int merge(int i, int j){
return UFDS[p(i)] = p(j);
}
int N;
void findRoad(){
for(int i=1; i<=N; i++){
// if(UFDS[i]==i){
for(int j=i+1; j<=N; j++){
if(p(j)!=p(i)){
//both i and j are leaders of their group
/* int *f = new int[110], *s = new int[110];
int fs=0, ss=0;
for(int x=1; x<=N; x++){
if(p(x)==i){
f[fs++] = x;
} else if(p(x)==j){
s[ss++] = x;
}
}
if(query(fs, ss, f, s)){
//found between which two sets a road has been built
merge(i, j);
setRoad
}
*/ int f[] = {i}, s[] = {j};
if(query(1, 1, f, s)){
merge(i, j);
setRoad(i, j);
return;
}
}
}
// }
}
}
void run(int NN){
N = NN;
for(int n=0; n<=N; n++){
UFDS[n] = n;
}
for(int n=1; n<N; n++)
findRoad();
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |