Pick | 프로그래밍의 벗 PivotOJ
PivotOJ

Pick

시간 제한: 1000ms메모리 제한: 1024MB출처: CHC 2018 Croatian Olympiad in InformaticsBOJ 15626
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

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 AA denotes its area, ii the number of points with integer coordinates located inside the polygon, and bb the number of points with integer coordinates located on its edges (including the polygon’s vertices), then it always holds:

A=i+b21A = i + \frac{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:

  • aa horizontal sticks of length 11,
  • bb vertical sticks of length 11,
  • cc diagonal sticks of length 2\sqrt{2} that form a 4545^\circ angle with the positive part of xx-axis,
  • dd diagonal sticks of length 2\sqrt{2} that form a 135135^\circ angle with the positive part of xx-axis.
[이미지 1] [이미지 2]
Figure 2: For the polygon above: A=8A = 8, i=4i = 4, b=10b = 10. 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”.

입력

The first line of input contains four integers aa, bb, cc, dd from the task.

출력

You must output n lines where n=a+b+c+dn = a + b + c + d. In the jjth line, output integers xjx_j and yjy_j — the coordinates of the jjth polygon vertex. The first polygon vertex must be (0,0)(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

입력
1 1 1 0
출력
0 0
1 1
0 1

예제 2

입력
0 0 6 4
출력
0 0
1 1
2 2
3 3
2 4
1 3
0 2
-1 3
-2 2
-1 1
코드를 제출하려면 로그인하세요.