QOJ.ac

QOJ

時間限制: 10.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#6999. 嵌套三角形

统计

Jamilah 痴迷于共享公共边的嵌套三角形。现在,她在平面上选择了两个点 $P$ 和 $Q$ 作为枢轴。她还提供了其他一些点 $A_1, A_2, \dots, A_{n-1}$ 和 $A_n$,其中没有点位于经过点 $P$ 和 $Q$ 的直线上。

作为同样感兴趣的人,请你找出嵌套三角形组的最大规模,并给出一个规模最大且字典序最小的可行解。

一组以 $P$ 和 $Q$ 为枢轴的嵌套三角形,是指 Jamilah 提供的点的一个列表,记为 $A_{v_1}, A_{v_2}, \dots, A_{v_k}$,使得对于任何 $i \ge 2$,点 $A_{v_i}$ 位于三角形 $PQA_{v_{i-1}}$ 的内部(不包含边界)。

如果对于任何其他可行解 $u_1, u_2, \dots, u_k$,满足 $v_1 < u_1$,或者存在一个整数 $i$ ($1 \le i < k$) 使得 $v_1 = u_1, v_2 = u_2, \dots, v_i = u_i$ 但 $v_{i+1} < u_{i+1}$,则称解 $v_1, v_2, \dots, v_k$ 为字典序最小的解。

输入格式

输入包含多个测试用例,第一行是一个正整数 $T$,表示测试用例的数量,最多为 $1000$。

对于每个测试用例,第一行包含四个整数 $x_P, y_P, x_Q, y_Q$,分别是点 $P$ 和 $Q$ 的坐标。第二行包含一个整数 $n$ ($1 \le n \le 10^5$),表示 Jamilah 提供的其他点的数量。接下来的 $n$ 行,每行包含两个整数,第 $i$ 行表示点 $A_i$ 的坐标。

我们保证测试用例中的所有点都是不同的,所有坐标都在 $-10^9$ 到 $10^9$ 的范围内,且所有测试用例中 $n$ 的总和不超过 $10^6$。

输出格式

对于每个测试用例,首先输出一行 Case #x: y,其中 $x$ 是从 1 开始的测试用例编号,$y$ 是嵌套三角形组的最大规模。接下来的 $y$ 行,每行包含一个整数,第 $i$ 行的整数为 $v_i$。

样例

样例输入 1

3
0 0 10 0
6
5 1
5 2
5 3
6 4
6 5
6 6
0 0 10 10
9
1 6
2 3
4 7
6 8
8 2
9 3
7 6
2 4
2 7
0 10 10 0
9
0 0
0 2
2 0
0 4
4 0
0 6
6 0
0 8
8 0

样例输出 1

Case #1: 6
6
5
4
3
2
1
Case #2: 3
1
3
2
Case #3: 1
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.