Lang:Java
Edit12345678910111213141516171819202122232425262728293031import java.util.*;class UnionFind {HashMap<String, String> father = new HashMap<String, String>();String find(String x){String parent = father.get(x);while (parent != father.get(parent)) {parent = father.get(parent);}return parent;}void union(String x, String y){String fa_x = find(x);String fa_y = find(y);if (fa_x != fa_y) {father.put(fa_x, fa_y);}}}public class Main {public static void main(String[] args) {Scanner in = new Scanner(System.in);int n = in.nextInt();HashMap<String, String> map = new HashMap<String, String>();HashMap<String, ArrayList<String>> usermap = new HashMap<String, ArrayList<String>>();UnionFind uf = new UnionFind();ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();for (int times = 0; times < n; times++) {String username = in.next();uf.father.put(username, username);int num = Integer.valueOf(in.next());for (int i = 0; i < num; i++) {