P15786 [JAG 2025 Summer Camp #3] Copy, Reflect, and Paste

Description

You are given a polygon $P$ with $N$ vertices, which is not necessarily convex. Initially, let $Q = P$. You can perform the following operation on $Q$ any number of times: - Choose a line segment of positive length lying on the boundary of $Q$, and let $Q'$ be the figure obtained by reflecting $Q$ across the line containing this segment. - If the interiors of $Q$ and $Q'$ intersect, the process ends immediately. - Otherwise, update $Q$ to the union of $Q$ and $Q'$. Determine whether the operation can be repeated indefinitely. In other words, determine whether it is possible to perform the operation at least $M$ times for every positive integer $M$. :::align{center} ![](https://cdn.luogu.com.cn/upload/image_hosting/drsd3jhb.png) :::

Input Format

The input consists of multiple test cases. The first line contains an integer $T$ ($1 \leq T \leq 100$), representing the number of test cases. $T$ test cases follow. Each test case is given in the following format. $$\begin{aligned} & N \\ & x_{1} \ y_{1} \\ & \vdots \\ & x_{N} \ y_{N} \end{aligned}$$ For each test case, the first line contains an integer $N$ ($3 \leq N \leq 10\,000$), representing the number of vertices of the polygon. Each of the following $N$ lines contains two integers $x_i$ and $y_i$, representing that the $i$-th vertex of polygon $P$ has coordinates $(x_i, y_i)$. These points satisfy the following conditions: - $-10^{9} \leq x_{i}, y_{i} \leq 10^{9}$ - The vertices of polygon $P$ are given in counterclockwise order. - $P$ is a simple polygon; in particular, no interior angle equals $180^{\circ}$.

Output Format

Output $T$ lines. For each test case, output "Yes" if it is possible to perform the operation infinitely many times, and "No" otherwise.