A823.Paint by Rectangles--Platinum

NOI/NOI+/CTSC

USACO

通过率:0%

时间限制:4.00s

内存限制:128MB

题目描述

After her previous
artwork
was met with
critical acclaim, Bessie was offered a job designing painting sets. She
designs these paintings by choosing NN 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 4 seconds (twice the default).

输入格式

The first line contains two integers, NN and TT. Each of the next NN lines contains four integers x1x_1, y1y_1, x2x_2, and y2y_2 describing one rectangle. The points (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2) are its bottom-left and top-right corners, respectively.

输出格式

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
    

说明/提示

In the first example, there are two white regions and two black regions, for a total of four. The boundaries of the rectangles are connected, so this example satisfies the condition for test cases 8–10 when T=1T=1.

In the second example, the boundary of the rectangle in the upper-right is not connected to the other rectangle boundaries.

数据范围

所有数据满足 1≤N≤1051\le N\le10^5、T∈{1,2}T\in\{1,2\};每个矩形满足 1≤x1<x2≤2N1\le x_1<x_2\le2N、1≤y1<y2≤2N1\le y_1<y_2\le2N。所有 xix_i 构成 1,2,…,2N1,2,\ldots,2N 的一个排列,所有 yiy_i 也构成该集合的一个排列;题目保证任意两条边不共线。此外:

测试点编号 数据范围
03–04 N≤103N\le10^3
05–07 任意两个矩形的边界不相交
08–10 T=1T=1,且所有矩形边界连通
11–13 T=2T=2,且所有矩形边界连通
14–18 T=1T=1
19–23 T=2T=2

输入解题思路,AI测评打分。不知道怎么写?

首页