小希的迷宫 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 36142 Accepted Submission(s): 11052 Problem Description 上次Gardon的迷宫城堡小希玩了
统计无向图中无法互相到达点对数 并查集合并,使用一个数组维护集合个数。 class Solution {static int arr[], cnt[];public long countPairs(int n, int[][] edges) {arr = new int[n];cnt = new int[n];for (int i = 0; i < n; i++) {arr[i] = i;