#P17430. [ICPC 2018 Xuzhou R] Rikka with Illuminations

    ID: 19932 远端评测题 10000ms 512MiB 尝试: 0 已通过: 0 显示难度提高+/省选− 上传者: 标签>动态规划 DP计算几何2018Special JudgeICPC

[ICPC 2018 Xuzhou R] Rikka with Illuminations

Problem Description

Rikka loves convex polygons, so she decides to install some illuminants to embellish polygons.

Now she has a large convex polygon with nn sides. She also has mm different points strictly outside the polygon which are all legal positions to install illuminants.

An illuminant can light up some exterior boundaries of the polygon.

Rikka wants to install some illuminants to light up all exterior boundaries of the polygon. She asks you to calculate the least number of illuminants which she needs and provide a feasible scheme.

Input Format

The input contains several test cases, and the first line contains a single integer TT (1≤T≤1001 \le T \le 100), the number of test cases.

For each test case, the first line contains two integers nn (3≤n≤10003 \le n \le 1000) and mm (1≤m≤10001 \le m \le 1000).

Each of the following nn lines describes a vertex on the convex polygon with two integers xx and yy (∣x∣,∣y∣≤109|x|, |y| \le 10^9), the Cartesian coordinates of the vertex. All these vertices are given in counter-clockwise order and any three of them are not collinear.

Then the following mm lines contain mm different points outside the polygon describing all legal positions to install illuminants. Each of them contains two integers xx and yy (∣x∣,∣y∣≤109|x|, |y| \le 10^9), the Cartesian coordinates of a legal position. They are numbered from 11 to mm. All these positions would not lie in some extension lines for the sides of the polygon.

Output Format

For each test case, if it's impossible to light up all exterior boundaries of the polygon, output a single line with a single integer −1-1. Otherwise, output two lines. Firstly, output a line with a single integer kk, representing the least number of illuminants Rikka needs to light up all the boundaries. Then, output a line with kk space-separated distinct integers, describing a feasible scheme, each of which is the index of a selected position.

All feasible schemes are allowed, so you can output any of them.

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