QOJ.ac

QOJ

时间限制: 8.0 s 内存限制: 512 MB 总分: 100 可 Hack ✓

#15547. 斜率

统计

平面上有 $n$ 个点 $(x_i, y_i)$,且所有 $x_i$ 互不相同。

你需要处理 $q$ 次查询。每次查询给定一个矩形 $[x_l, x_r] \times [y_l, y_r]$,该矩形确定了 $n$ 个给定点的一个子集;该子集由所有满足 $x_l \le x_i \le x_r$ 且 $y_l \le y_i \le y_r$ 的点 $i$ 组成。

查询的答案是 $\left|\frac{y_i-y_j}{x_i-x_j}\right|$ 的最小值,其中 $i$ 和 $j$ 是上述子集中的两个不同的点,且 $|a|$ 表示 $a$ 的绝对值。如果该子集包含少于两个点,请参阅输出格式部分。

输入格式

第一行包含两个正整数 $n$ 和 $q$($1 \le n \le 7 \times 10^3$ 且 $1 \le q \le 7 \times 10^5$)。

接下来的 $n$ 行中,第 $i$ 行包含两个整数 $x_i$ 和 $y_i$($-10^9 \le x_i, y_i \le 10^9$)。

接下来的 $q$ 行中,每行包含四个整数 $x_l, x_r, y_l$ 和 $y_r$($-10^9 \le x_l \le x_r \le 10^9$ 且 $-10^9 \le y_l \le y_r \le 10^9$),表示一次查询。

输出格式

输出包含 $q$ 行。第 $i$ 行包含两个非负且互质的整数 $a$ 和 $b$,表示第 $i$ 次查询的答案 $\frac{a}{b}$。如果 $a = 0$,你应该输出 0 1。如果该子集包含少于两个点,你应该输出 1 0

样例

输入样例 1

5 5
16 12
11 14
15 6
1 14
2 16
1 2 13 17
10 17 12 14
1 17 11 19
15 16 6 12
11 15 1 19

输出样例 1

2 1
2 5
0 1
6 1
2 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.