logo AlgoBeat OnlineJudge
登录 注册

#215826. [JAG 2025 Summer Camp #2] Strange House

内存限制:1024 MiB 时间限制:4000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

As a strange house inspector you are inspecting a house consisting of rooms. Each room is a rectangle in the -plane, and each of its edges is parallel to the - or -axis. Two rooms can touch but do not overlap.

Let us say that two rooms are adjacent if their borders share a segment of a positive length. It is guaranteed that one can reach from any of the rooms to any other room by repeatedly moving to an adjacent room. In addition, if the borders of two rooms share only a single point, there is another room which is adjacent to both rooms.

Figure D-1 depicts the Sample Input 1. On the other hand, Figures D-2 and D-3 are invalid inputs.

:::align{center} :::

In Figure D-1 you may have found strange spaces surrounded by rooms. More precisely, a simple polygon is called a strange space if the following conditions are satisfied.

  • The polygon and any room do not overlap.
  • For any point on the border of the polygon, there is a room whose border contains that point.

Your task is to find all the strange spaces of the house. Output the number of strange spaces and the sum of their areas.

输入格式

The input consists of a single test case of the following format.

The first line contains an integer () representing the number of rooms in the house. Each of the following lines contains four integers satisfying and . Each line represents that corners of the -th room are , , and . These rooms satisfy all the conditions explained in the problem statement.

输出格式

Output two lines. The first line should contain the number of strange spaces of the house. The second line should contain the sum of areas of these strange spaces.

样例

样例输入 1

10
10 30 10 90
30 90 10 30
10 30 90 110
30 90 90 110
30 80 40 90
90 120 10 110
120 170 10 50
120 130 60 110
130 170 60 110
130 170 50 60

样例输出 1

2
1200

样例输入 2

7
0 3 0 24
3 9 0 24
9 15 0 12
9 15 12 24
15 17 0 8
15 17 8 16
15 17 16 24

样例输出 2

0
0