Problem list
Log in
#coci00492 · COI 2018

Pick

Unrated 1.0 s 256 MB

1 sekunda / 1024 MiB / 100 points Mirko recently read about Pick’s theorem that says the following: in the coordinate system, if we draw a polygon whose vertices are points with integer coordinates, and if $A$ denotes its area, $i$ the number of points with integer coordinates located inside the polygon, and $b$ the number of points with integer coordinates located on its edges (including the polygon’s vertices), then it always holds: $A = i$ + ^{b} 2 ^{−}^{1}^{.} In order to test the theorem, Mirko used his smart board to create a polygon from magnetic sticks that have, during the night, sunk to the bottom of the board because due to gravity. Now, Mirko wants to construct a polygon of the minimal possible area while using all the sticks he found. Mirko can move the sticks anywhere on his board, but he must not rotate them. Mirko is equipped with the following:

  • $a$ horizontal sticks of length 1,
  • $b$ vertical sticks of length 1,
  • $c$ diagonal sticks of length √ 2 that form a $45^{◦}$angle with the positive part of x-axis,
  • $d$ diagonal sticks of length √ 2 that form a $135^{◦}$angle with the positive part of x-axis. Figure 2: For the polygon above: $A = 8$, $i = 4$, $b = 10$. a b c d Figure 3: The sticks Mirko is equipped with. Determine the polygon of the minimal possible area that can be obtained so that all the sticks are used. You can assume that the input data is such that it is possible to construct at least one such polygon. Also, it is possible to score partial points if, using all of the given sticks, you construct a valid polygon (that is not necessarily of the minimal possible area). For more details, consult the section “Scoring”.

Input

The first line of input contains four integers a, b, c, d from the task.

Output

You must output $n$ lines where $n = a + b + c + d$. In the $j$-th line, output integers $xj$ and $yj$ — the coordinates of the $j$-th polygon vertex. The first polygon vertex must be (0, 0), and the other vertices can be printed in an arbitrary direction (either positive or negative). It is allowed that the consecutive polygon sides are parallel, but the polygon cannot touch or intersect itself. 1 sekunda / 1024 MiB / 100 points

Example 1

Input
1 1 1 0
Output
0 0
1 1
0 1

Example 2

Input
0 0 6 4
Output
0 0
1 1
2 2
3 3
2 4
1 3
0 2
-1 3
-2 2
-1 1
Source
COI 2018
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code