File size: 767 Bytes
c574d3a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
package torea;
import java.lang.StringBuilder;
public class FakeboolQuickFind{
public static void main(String[] args){
Kattio io = new Kattio(System.in, System.out);
int nrUsers = io.getInt();
int nrUnions = io.getInt();
UnionFind.QuickFind qf = new UnionFind.QuickFind(nrUsers);
for(int i = 0; i< nrUnions; i++){
int a = io.getInt();
int b = io.getInt();
qf.union(a, b);
}
StringBuilder sb = new StringBuilder();
for(int i = 0; i < nrUsers; i++){
sb.append(qf.id[i]).append(" ");
// if (i != nrUsers - 1) sb.append(" ");
}
io.print(sb);
io.flush();
io.close();
}
} |