QOJ.ac

QOJ

時間限制: 8.0 s 記憶體限制: 1024 MB 總分: 100 难度: [顯示] 可 Hack ✓

#7015. 六花与照明

统计

Rikka 热爱凸多边形,因此她决定安装一些照明灯来装饰多边形。

现在她有一个拥有 $n$ 条边的巨大凸多边形。她还有 $m$ 个位于多边形外部的不同点,这些点都是安装照明灯的合法位置。

一个照明灯可以照亮多边形的部分外边界。

Rikka 想要安装一些照明灯以照亮多边形的所有外边界。她请求你计算她所需的最少照明灯数量,并提供一个可行的方案。

输入格式

输入包含多个测试用例,第一行包含一个整数 $T$ ($1 \le T \le 100$),表示测试用例的数量。

对于每个测试用例,第一行包含两个整数 $n$ ($3 \le n \le 1000$) 和 $m$ ($1 \le m \le 1000$)。

接下来的 $n$ 行,每行描述凸多边形的一个顶点,包含两个整数 $x$ 和 $y$ ($|x|, |y| \le 10^9$),表示顶点的笛卡尔坐标。所有顶点均按逆时针顺序给出,且任意三点不共线。

随后的 $m$ 行,每行包含一个位于多边形外部的点,描述所有合法的照明灯安装位置。每行包含两个整数 $x$ 和 $y$ ($|x|, |y| \le 10^9$),表示合法位置的笛卡尔坐标。这些位置按 $1$ 到 $m$ 编号。所有这些位置都不会落在多边形边的延长线上。

输出格式

对于每个测试用例,如果无法照亮多边形的所有外边界,输出一行,包含一个整数 $-1$。否则,输出两行。第一行输出一个整数 $k$,表示 Rikka 照亮所有边界所需的最少照明灯数量。第二行输出 $k$ 个以空格分隔的互不相同的整数,描述一个可行方案,每个整数为所选位置的编号。

所有可行方案均被允许,因此你可以输出其中任意一个。

样例

输入 1

1
3 3
0 0
1 0
0 1
-1 -1
3 -1
-1 3

输出 1

2
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.