QOJ.ac

QOJ

Límite de tiempo: 8 s Límite de memoria: 2048 MB Puntuación total: 100

#15637. 点亮的摊位

Estadísticas

年复一年,你漫步在圣诞集市上,在热红酒的香气中与老朋友重逢。最近,物价高得离谱,仅仅度过几个夜晚就让你在经济上破产。今年,你决定扭转局面,自己开一个卖热红酒的摊位。但竞争非常激烈,事实证明,又一个价格高得离谱的摊位远没有你预期的那样有利可图。

为了脱颖而出,你设计了一个困难的谜题。如果顾客能解开它,他们就可以免费喝到饱。天真的顾客往往愿意为此支付比平时更多的钱。

这个谜题由挂在墙上的 $n$ 根线段状的霓虹灯管组成。它们要么是水平方向的,要么是垂直方向的。任意两根水平灯管都不会重叠或接触,且任意两根垂直灯管也不会重叠或接触,但一根垂直灯管可以与一根水平灯管相交或接触。玩家被允许以任何他们喜欢的方式旋转和/或移动至多一根灯管。目标是使墙上至少出现一个被照亮的霓虹灯正方形。该正方形的所有四条边都必须完全被霓虹灯管覆盖,但灯管的长度可以长于正方形的边长。

灯管允许位于正方形的内部或与其边界相交。被移动的灯管在放置时,允许与其他共线的灯管接触、部分重叠或完全重叠。

你想让这个谜题尽可能难,但如果谜题无解,你就会惹上德国立法者的麻烦,因为他们的规定非常严格。给定一个谜题,请判断是否可以通过移动和/或旋转至多一根灯管来拼出一个正方形。

输入格式

输入包含:

  • 第一行包含一个整数 $t$ ($1 \le t \le 20\,000$),表示测试用例的数量。
  • 对于每个测试用例,输入包含:

    • 第一行包含一个整数 $n$ ($4 \le n \le 2 \cdot 10^5$),表示霓虹灯管的数量。
    • 接下来的 $n$ 行,每行包含四个整数 $x_1, y_1, x_2$ 和 $y_2$ ($0 \le x_1, x_2, y_1, y_2 \le 10^9$,$x_1 \le x_2$,$y_1 \le y_2$,且 $x_1 = x_2$ 和 $y_1 = y_2$ 有且仅有一个成立),其中 $(x_1, y_1)$ 和 $(x_2, y_2)$ 是一根灯管的端点。

所有测试用例的灯管总数不超过 $2 \cdot 10^5$。

所有灯管要么是垂直的,要么是水平的。对于每个测试用例,初始配置中不存在两根重叠或接触的水平灯管,也不存在两根重叠或接触的垂直灯管。请注意,水平灯管可以与垂直灯管相交和接触。

输出格式

对于每个测试用例,如果可以通过移动和/或旋转至多一根灯管来拼出一个正方形,则输出 "yes",否则输出 "no"。

样例

输入样例 1

5
4
0 0 0 1
0 1 1 1
1 0 1 1
0 0 1 0
4
0 0 0 4
0 4 4 4
4 0 4 4
10 10 10 14
5
0 0 0 4
0 4 4 4
3 1 4 1
4 0 4 4
10 10 10 13
5
0 0 0 4
0 4 4 4
4 0 4 4
3 0 4 0
10 10 10 13
9
1 3 6 3
2 1 2 8
2 7 8 7
4 6 6 6
6 7 6 8
5 5 7 5
6 2 6 4
7 3 11 3
9 1 9 5

输出样例 1

yes
yes
no
yes
yes

说明

图 I.1:左图显示了样例输入 1 中第五个测试用例的初始灯管配置。右图中,紫色的霓虹灯管被旋转并移动,从而拼成了一个 $4 \times 4$ 的正方形。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.