SW练习_栅栏2_unionfind_凸包

这篇博客探讨了在SW练习中遇到的栅栏问题,结合UnionFind数据结构进行了解决,并提及了如何优化连接重新挂载的部分,同时涉及到凸包算法的应用。
摘要由CSDN通过智能技术生成

 连接重新挂载的部分可以优化

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值