QOJ.ac

QOJ

时间限制: 8 s 内存限制: 2048 MB 总分: 100

#16808. 曼哈顿干涉

统计

在 LOneLand,居民们在选择电信公司时有许多选择。根据政府规定,每家电信公司必须恰好拥有两座手机信号塔。注册了某家公司的手机会通过曼哈顿距离(也称为 L1 范数)寻找最近的信号塔并连接到该信号塔。两个点 $(x_1, y_1)$ 和 $(x_2, y_2)$ 之间的曼哈顿距离为 $|x_1 - x_2| + |y_1 - y_2|$。

如果一部手机到其所属电信公司的两座信号塔的曼哈顿距离相等,那么该设备就会受到“曼哈顿干扰”,并且无法连接到任何一座信号塔。为了提高手机的可靠性,LOneLand 的居民为他们的设备配备了来自两家不同公司的 SIM 卡。不幸的是,如果手机处于两张 SIM 卡同时受到曼哈顿干扰的位置,手机就会爆炸!

你的任务是计算有多少对电信公司,使得同时配备这两家公司的 SIM 卡是危险的。也就是说,计算有多少对电信公司,满足存在至少一个点(不一定具有整数坐标),使得配备了这两家公司 SIM 卡的手机在该点会发生爆炸。如果一个对中包含的某家公司在另一个对中没有出现,则认为这两个对是不同的。

输入格式

输入的第一行包含一个整数 $n$($2 \le n \le 1.5 \cdot 10^5$),表示电信公司的数量。

接下来的 $n$ 行,每行包含四个整数 $x_1, y_1, x_2, y_2$($-10^8 \le x_1, y_1, x_2, y_2 \le 10^8$),表示某家电信公司的两座信号塔的坐标,分别位于 $(x_1, y_1)$ 和 $(x_2, y_2)$。所有信号塔的位置均互不相同。

输出格式

输出一个整数,表示同时配备其 SIM 卡是危险的电信公司对数。

样例

样例输入 1

3
0 0 1 3
10 10 11 13
4 5 9 4

样例输出 1

2

说明

样例 1 解释

有两对电信公司应该被计入答案:

图 I.1:样例说明图示。

  • 公司 1 和公司 3:如果手机同时连接这两家公司,它将在点 $(6, 1)$ 处爆炸,因为该点到公司 1 的两座信号塔的距离均为 7 个单位,到公司 3 的两座信号塔的距离均为 6 个单位。
  • 公司 2 和公司 3:如果手机同时连接这两家公司,它将在点 $(7, 12)$ 处爆炸。

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.