061 能否完美地拼成矩形
Table of Contents

ac

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Node{
    int x1;
    int y1;
    int x2;
    int y2;

    public Node() {
    }

    public Node(int x1, int y1, int x2, int y2) {
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
    }

    public int area(){
        return Math.abs(x1 - x2) * Math.abs(y1 - y2);
    }
}

public class Main {
    public static Scanner sc = new Scanner(System.in);

    public static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        String line = reader.readLine();
        int n = Integer.valueOf(line);
        List<Node> list = new ArrayList<>(n);
        int totalArea = 0;
        for(int i=0;i<n;i++){
            line = reader.readLine();
            String[] strArr = line.split(" ");
            int x1 = Integer.valueOf(strArr[0]);
            int y1 = Integer.valueOf(strArr[1]);
            int x2 = Integer.valueOf(strArr[2]);
            int y2 = Integer.valueOf(strArr[3]);
            Node node = new Node(x1,y1,x2,y2);
            list.add(node);
            totalArea += node.area();
        }

        Node notTotal = new Node();

        list.sort((n1, n2)->{
            if(n1.x1 < n2.x1){
                return -1;
            }else if(n1.x1 == n2.x1){
                return n1.y1 - n2.y1;
            }
            return 1;
        });
        notTotal.x1 = list.get(0).x1;
        notTotal.y1 = list.get(0).y1;

        list.sort((n1, n2)->{
            if(n1.x2 < n2.x2){
                return -1;
            }else if(n1.x2 == n2.x2){
                return n1.y2 - n2.y2;
            }
            return 1;
        });
        notTotal.x2 = list.get(list.size() - 1).x2;
        notTotal.y2 = list.get(list.size() - 1).y2;

        if(notTotal.area() == totalArea){
            System.out.print("Yes");
        }else {
            System.out.print("No");
        }
    }

}
/*
4
1 1 3 3
3 1 4 2
1 3 2 4
3 2 4 4

No

5
1 1 3 3
3 2 4 3
3 2 4 4
1 3 2 4
2 3 3 4

No

5
1 1 3 3
3 1 4 2
3 2 4 4
1 3 2 4
2 3 3 4

Yes
 */