连接重新挂载的部分可以优化
package com.company.real;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
//栅栏2 20190731真题
public class Zhalan_20190731 {
static int[] set;//保存点的父id
static Map<String,Integer> map;// 1_1,1
static Node0731[] nodes;//保存nodes节点,100000个铁丝网,最多可以连接100001个点
static List<Edge0731>[] list;//存放每一个点(使用find后的数据) 相连的边
static int N;
static int Max_x=1087654321;
//static int Max_y=2137654321;
public static void main(String[] args) throws Exception{
//System.setIn(new FileInputStream("C:\\Users\\XAGDC\\Desktop\\32Pro\\sample_input.txt"));
System.setIn(new FileInputStream("C:\\Users\\XAGDC\\Desktop\\32Pro\\eval_input.txt"));
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer(reader.readLine());
int T=Integer.parseInt(st.nextToken());//测试用例的个数
for (int zz = 0; zz < T; zz++) {
map=new HashMap<String,Integer>();
nodes=new Node0731[100001];
st=new StringTokenizer(reader.readLine());
N=Integer.parseInt(st.nextToken());//铁丝网的个数
set=new int[N+1];
list=new ArrayList[N+1];
for (int i = 0; i <set.length ; i++) {
set[i]=i;
list[i]=new ArrayList<Edge0731>();
}
int index=-1;
for (int i = 0; i <N ; i