Problem 3048 --Calabash and Landlord

3048: Calabash and Landlord

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $1$ 正确数量 $1$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Calabash is the servant of a landlord. The landlord owns a piece of land, which can be regarded as an infinite 2D plane. 

One day the landlord set up two orthogonal rectangular-shaped fences on his land. He asked Calabash a simple problem: how many nonempty connected components is my land divided into by these two fences, both finite and infinite? Calabash couldn't answer this simple question. Please help him! 

Recall that a connected component is a maximal set of points not occupied by the fences, and every two points in the set are reachable without crossing the fence. 
The first line of input consists of a single integer T (1≤T≤10000), the number of test cases. 

Each test case contains two lines, specifying the two rectangles. Each line contains four integers x1,y1,x2,y2 (0≤x1,y1,x2,y2≤109,x1<x2,y1<y2), where (x1,y1),(x2,y2) are the Cartesian coordinates of two opposite vertices of the rectangular fence. The edges of the rectangles are parallel to the coordinate axes. The edges of the two rectangles may intersect, overlap, or even coincide. 
For each test case, print the answer as an integer in one line.
3
0 0 1 1
2 2 3 4
1 0 3 2
0 1 2 3
0 0 1 1
0 0 1 1
3
4
2

推荐代码 查看3048 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$116 $ms] 淡意的温柔 591146 2020-06-06 08:45:31
内存最少[$0 $KB] 淡意的温柔 591146 2020-06-06 08:45:31
第一AC 淡意的温柔 591146 2020-06-06 08:45:31
第一挑战 淡意的温柔 591146 2020-06-06 08:45:31

赛题来源/所属竞赛 2019 Multi-University Training Contest 8 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛