题目收集
题目列表题单
返回列表

Convex II

CodeforcesP0043· 4000ms· 1024 MB· ZJU Summer 2026 Contest 4原题链接
计算几何

创建于 2026/07/17 · 更新于 2026/07/17

题目描述

You are given kkk pairwise disjoint convex polygons on the plane.

Determine whether there exists a point OOO and kkk pairwise distinct rays starting from OOO such that these rays divide the plane into kkk closed angular regions, and each polygon can be assigned to exactly one of these regions, with no two polygons assigned to the same region.

The regions include their boundary rays. Therefore, it is allowed that a boundary ray passes through vertices or edges of polygons. It is also allowed that vertices of different polygons lie on the same boundary ray.

You only need to decide whether such a point OOO and such kkk rays exist.It is guaranteed for 0≤ϵ<10−60 \le \epsilon \lt 10^{-6}0≤ϵ<10−6, that the answer does not change if the input coordinates modified by ϵ\epsilonϵ.

输入格式

The first line contains an integer TTT (1≤T≤20)(1 \le T \le 20)(1≤T≤20), the number of test cases.

For each test case, the first line contains an integer kkk (2≤k≤20)(2 \le k \le 20)(2≤k≤20), the number of convex polygons.

For each polygon iii, the first line contains an integer nin_ini​ (3≤ni, ∑i=1kni≤120)(3 \le n_i,\ \sum_{i=1}^{k} n_i \le 120)(3≤ni​, ∑i=1k​ni​≤120), the number of vertices of the iii-th polygon.

Each of the next nin_ini​ lines contains two integers xi,jx_{i,j}xi,j​ and yi,jy_{i,j}yi,j​ (−103≤xi,j,yi,j≤103)(-10^3 \le x_{i,j}, y_{i,j} \le 10^3)(−103≤xi,j​,yi,j​≤103), the coordinates of the jjj-th vertex of the iii-th polygon.

The vertices of each polygon are given in counterclockwise order. Each polygon is convex and has positive area. The given polygons are pairwise disjoint.

It is guaranteed that the sum of ∑ni\sum n_i∑ni​ over all test cases does not exceed 120120120.

输出格式

For each test case, output one line.

Output YES if there exists such a point OOO and such kkk rays. Otherwise, output NO.

样例输入 #1

3
2
4
-4 -1
-2 -1
-2 1
-4 1
4
2 -1
4 -1
4 1
2 1
4
4
-6 3
-2 4
-3 15
-7 14
4
-1 -3
10 -2
9 3
-2 2
4
2 -11
3 -11
4 -7
1 -8
4
4 -10
15 -9
14 -8
5 -8
4
4
-8 -8
-6 -8
-6 -6
-8 -6
4
6 -8
8 -8
8 -6
6 -6
4
6 6
8 6
8 8
6 8
4
-8 6
-6 6
-6 8
-8 8

样例输出 #1

YES
NO
YES