#567
Unrated
Paint by Rectangles
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

After her previous artwork was met with critical acclaim, Bessie was offered a job designing painting sets. She designs these paintings by choosing 1N1051\le N\le 10^5 axis-aligned rectangles in the plane such that no two edges are collinear. The boundaries of these rectangles define the boundaries of the painting's colored regions.

Still being an avant-garde artist, Bessie decides that the painting should resemble a Holstein cow. More specifically, each region formed by the rectangles is colored either black or white, no two adjacent regions have the same color, and the region outside of all the rectangles is colored white.

After choosing the rectangles, Bessie would like you to output one of two things based on a parameter TT: If T=1T=1, output the total number of regions.If T=2T=2, output the number of white regions followed by the number of black regions.

Note: the time limit for this problem is 4s, twice the default.

입력

The first line contains NN and TT.

The next NN lines each contain the description of a rectangle in the form (x1,y1),(x2,y2)(x_1,y_1), (x_2,y_2) where 1x1<x22N1\le x_1<x_2\le 2N and 1y1<y22N1\le y_1<y_2\le 2N. (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) are the bottom left and top right corners of the rectangle respectively.

It is guaranteed that all the xix_i form a permutation of 12N1\ldots 2N, and the same holds for all the yiy_i.

출력

A single integer if T=1T=1, otherwise two separated by spaces.

예제 입력 1

2 1
1 1 3 3
2 2 4 4

예제 출력 1

4

예제 입력 2

5 2
1 5 3 6
5 4 7 9
4 1 8 3
9 8 10 10
2 2 6 7

예제 출력 2

4 5

점수

Test cases 3-4 satisfy N103N\le 10^3.In test cases 5-7, no two rectangle boundaries intersect.In test cases 8-10, T=1T=1 and the boundaries of all rectangles are connected.In test cases 11-13, T=2T=2 and the boundaries of all rectangles are connected.In test cases 14-18, T=1T=1.In test cases 19-23, T=2T=2.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.