#P16864. [GKS 2021 #G] Simple Polygon

    ID: 19191 远端评测题 1000ms 1024MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学计算几何2021Special JudgeGoogle Kick Start

[GKS 2021 #G] Simple Polygon

Problem Description

You are given 22 integers, the number of vertices NN and area AA. You need to construct a simple polygon of NN vertices such that the area of the polygon is exactly A2\frac{A}{2}, and all the vertices have non-negative integer coordinates with value up to 10910^9.

A simple polygon is one that:

  • Defines a closed area.
  • Does not have self-intersections, even at a single point.
  • No 22 consecutive edges form a straight angle.

Input Format

The 11st line of the input gives the number of test cases, TT. TT lines follow. The 11st line of each test case contains 22 integers, NN denoting the number of vertices and AA, denoting double the required area of the polygon.

Output Format

For each test case, output 11 line containing Case # xx: yy, where xx is the test case number (starting from 11) and yy is IMPOSSIBLE if it is not possible to construct a polygon with the given requirements and POSSIBLE otherwise.

If you output POSSIBLE, output NN more lines with 22 integers each. The ii-th line should contain 22 integers XiX_i and YiY_i which denote the coordinates of the ii-th vertex. For each ii, the coordinates should satisfy the 0Xi,Yi1090 \le X_i, Y_i \le 10^9 constraints. Vertices of the polygon should be listed in consecutive order (vertexivertex_i should be adjacent to vertexi1vertex_{i-1} and vertexi+1vertex_{i+1} in the polygon).

If there are multiple possible solutions, you can output any of them.

2
4 36
5 2
Case #1: POSSIBLE
2 5
6 5
8 2
0 2
Case #2: IMPOSSIBLE

Hint

In Sample Case #11, we can output the above quadrilateral with coordinates (2,5)(2, 5), (6,5)(6, 5), (0,2)(0, 2) and (8,2)(8, 2). The area of this quadrilateral is equal to 1818.

In Sample Case #22, there is no way to construct a polygon with 55 vertices and area equal to 11.

:::align{center} :::

Limits

1T1001 \le T \le 100.

1A1091 \le A \le 10^9.

Test Set 11

3N53 \le N \le 5.

Test Set 22

3N10003 \le N \le 1000.