#P16190. [COI 2018] Pick 皮克

    ID: 18103 远端评测题 1000ms 1024MiB 尝试: 0 已通过: 0 显示难度暂无评定 上传者: 标签>2018Special JudgeCOI(克罗地亚)

[COI 2018] Pick 皮克

Background

1 s, 1024 MB.

Problem Description

Mirko recently read about Pick’s theorem, which says: On a coordinate plane, if we draw a polygon whose vertices all have integer coordinates, let its area be AA, let the number of integer-coordinate points strictly inside the polygon be ii, and let the number of integer-coordinate points on the boundary of the polygon (including vertices) be bb. Then it always holds that:

A=i+b2−1A=i+\frac{b}{2}-1

To verify this theorem, Mirko used his smart whiteboard and made a polygon using magnetic sticks. Due to gravity, during the night the sticks may have slid down to the bottom of the whiteboard. Now, Mirko wants to build a polygon with the smallest possible area while using all the sticks he can find. Mirko may move the sticks on the whiteboard, but he must not rotate them. He has the following sticks:

  • aa horizontal sticks of length 1,
  • bb vertical sticks of length 1,
  • cc diagonal sticks of length 2\sqrt{2}, forming a 45°45\degree angle with the positive direction of the xx-axis,
  • dd diagonal sticks of length 2\sqrt{2}, forming a 135°135\degree angle with the positive direction of the xx-axis.

Figure 2: The polygon above: A=8A = 8, i=4i = 4, b=10b = 10.

Figure 3: The sticks Mirko has.

Determine a polygon with the minimum possible area that can be built such that all sticks are used. You may assume the input guarantees that at least one polygon can be constructed.

If you construct a valid polygon using all given sticks (not necessarily with minimum area), you can also get partial points. For more details, see the “Scoring” section.

Input Format

The first line contains four integers, which are a,b,c,da, b, c, d as described in the statement.

Output Format

Output nn lines, where n=a+b+c+dn = a + b + c + d. On the jj-th line, output integers xjx_j and yjy_j—the coordinates of the jj-th vertex of the polygon. The first vertex must be (0,0)(0, 0). The remaining vertices may be printed in any direction (clockwise or counterclockwise). Consecutive polygon edges are allowed to be parallel, but the polygon must not self-intersect or self-touch.

1 1 1 0

0 0
1 1
0 1

0 0 6 4

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

Hint

Constraints

In all subtasks, 0≤a,b,c,d≤1000 \le a, b, c, d \le 100 and a+b+c+d≥3a + b + c + d \ge 3.

Subtasks

::cute-table{three} | ID | Points | Constraints | |:--:|:--:|:--:| | 11 | 55 | c=d=0c = d = 0 | | 22 | 55 | a=b=0a = b = 0 | | 33 | 1010 | a+b+c+d≤6a + b + c + d \le 6 | | 44 | 1010 | a+b+c+d≤20a + b + c + d \le 20 | | 55 | 1010 | a+b+c+d≤40a + b + c + d \le 40 | | 66 | 1010 | a+b+c+d≤80a + b + c + d \le 80 | | 77 | 1010 | a+b+c+d≤150a + b + c + d \le 150 | | 88 | 1010 | a+b+c+d≤200a + b + c + d \le 200 | | 99 | 1010 | a+b+c+d≤300a + b + c + d \le 300 | | 1010 | 2020 | No additional constraints |

Scoring

If, for some test case, your solution does not output a valid polygon, then that subtask scores 00 points. If the output polygon is valid but not of minimum area, it can still receive partial points:

For test case jj, let rjr_j be the ratio of the output polygon’s area to the minimum possible area. For subtask kk, let zkz_k be the maximum of all rjr_j in subtask kk. The percentage score PkP_k is computed as follows: if zk≥3z_k \ge 3, then Pk=10P_k = 10. Otherwise:

Pk=258(3−zk)4+10P_k = \frac{25}{8}(3 - z_k)^4 + 10

Therefore, a non-optimal solution can obtain between 10%10\% and 60%60\% of the score in a subtask, depending on the polygon area ratio.

Translation source: GPT 4.1 mini.

Translated by ChatGPT 5