QOJ.ac

QOJ

Time Limit: 6 s Memory Limit: 2048 MB Total points: 100

#2434. 一次失败的切割

Statistics

入侵与犯罪预防公司 (ICPC) 致力于为家庭和企业构建入侵检测系统。国际大学生程序设计竞赛 (International Collegiate Programming Contest,巧合的是也简称为 ICPC) 正在考虑聘请该公司来保护存放下一届世界总决赛题目集的房间。

竞赛工作人员希望防止过去几年发生的入侵尝试,例如从建筑物外墙垂降通过窗户进入、爬过通风管道、冒充 Bill Poucher 以及创造性地使用攻击潜艇。因此,题目将被存放在一个只有一个门且没有其他出口的房间里。

ICPC(该公司)提议在门的四条边上安装传感器,并将成对的传感器用导线连接起来。如果有人打开门,任何连接的传感器对都会检测到这一点并触发警报。

然而,该系统有一个设计缺陷。入侵者可能会在开门前切断导线。为了评估系统的安全性,你需要确定切断所有导线所需的最少线段数量。图 H.1 展示了门上两种导线的配置(对应两个样例输入),以及能够穿过所有导线的最小规模切断方案。

图 H.1:样例输入 1 和 2 的示意图。

输入格式

输入的第一行包含三个整数 $n$、$w$ 和 $h$,分别表示安装的导线数量 ($1 \le n \le 10^6$) 以及门的尺寸 ($1 \le w, h \le 10^8$)。接下来有 $n$ 行,每行描述一根导线的放置位置。每行包含四个整数 $x_1, y_1, x_2$ 和 $y_2$ ($0 \le x_1, x_2 \le w, 0 \le y_1, y_2 \le h$),表示一根导线从 $(x_1, y_1)$ 连接到 $(x_2, y_2)$。每根导线连接门的两个不同侧边。没有任何导线固定在门的四个角上。输入中的所有位置坐标均不相同。

输出格式

输出能够穿过所有导线的最少数量的直线切断方案。首先,输出所需的切断次数。然后,每行输出一个切断方案,格式为 $x_1\ y_1\ x_2\ y_2$,表示连接 $(x_1, y_1)$ 和 $(x_2, y_2)$ 的切断线。每条切断线必须在门的两个不同侧边上开始和结束。切断线的起点或终点距离任何导线锚点或门的任何角落不得小于 $10^{-6}$。

切断方案可以按任意顺序输出。每条切断线的起点和终点坐标也可以按任意顺序输出。如果存在多组规模相同的最小切断方案,输出其中任意一组即可。

样例

样例输入 1

4 4 6
0 1 4 4
0 5 2 0
0 3 3 6
2 6 4 2

样例输出 1

1
0 4 4 3

样例输入 2

5 4 6
0 2 2 0
0 3 2 6
1 6 3 0
1 0 4 4
3 6 4 2

样例输出 2

2
0 4 4 4.5
0 1 4 1

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.