Logo Universal Online Judge

UOJ

时间限制:1 s 空间限制:1024 MB
统计

题面翻译

米尔科最近读到皮克定理,它说:在坐标系中,如果我们画 一个多边形,其顶点是具有整数坐标的点,如果 A 表示其面积,则 i 为数 位于多边形内的具有整数坐标的点的数量,以及 b 具有整数的点的数量 位于其边上的坐标(包括多边形的顶点),则它始终保持:

A = i + b/2 - 1。

为了测试这个定理,米尔科用他的智能板用磁棒创建了一个多边形, 在夜间,由于重力,沉到了板底。现在,米尔科想要 用他找到的所有木棍构造一个可能面积最小的多边形。米尔科可以移动 粘在他板上的任何地方,但他不能旋转它们。 Mirko 配备以下设备:

• 一根长度为 1 的水平木棍,

• b 长度为 1 的垂直棒,

• c 个长度为 √2 的对角棒,与 x 轴的正部分形成 45° 角,

• d 根长度为 √2 的对角棒,与 x 轴的正部分形成 135° 角。

14.png

确定可以得到的最小可能区域的多边形,以便使用所有的棍子。 您可以假设输入数据可以构造至少一个这样的多边形。

此外,如果使用所有给定的棍子构造一个有效的多边形,则可能会获得部分分数 (这不一定是最小的可能区域)。 有关详细信息,请参阅“评分”部分。

题目描述

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.

14.png

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 jth line, output integers xj and yj — the coordinates of the jth 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.

您必须输出 n 行,其中 n = a + b + c + d。 在第 j 行,输出整数 $x_j$ 和 $y_j$ — 第 j 个多边形顶点的坐标。 第一个多边形顶点必须是 (0, 0),其他顶点 可以在任意方向(正或负)打印。 允许连续 多边形边是平行的,但多边形不能接触或相交自身。

样例 #1

样例输入 #1

1 1 1 0

样例输出 #1

0 0
1 1
0 1

样例 #2

样例输入 #2

0 0 6 4

样例输出 #2

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

Scoring

In all subtasks, it holds 0 ≤ a, b, c, d ≤ 100 and a + b + c + d ≥ 3.

15.png

如果对于测试用例,您的解决方案没有输出由给定棒组成的有效多边形,那么它 对应的子任务得 0 分。

如果解决方案输出的有效多边形不属于 最小可能的区域,那么它可以根据以下规则获得部分分数。

对于测试用例 j,令 rj 表示获得的多边形与最小可能多边形的面积之比 区域。

对于子任务 k,我们用 zk 表示最大的数字 rj ,其中 j 是来自的测试用例 子任务 k。 子任务 k 的解决方案得分 Pk 的百分比取决于数量 zk 以下列方式:如果 zk ≥ 3,则 Pk = 10,否则计算为:

$P_k = \frac{25}{8} (3 − z_k)^4 + 10.$

因此,对于某个子任务,不是最优的解决方案可以得分在 10% 到 60% 之间, 取决于获得的多边形的面积与最佳多边形的面积之比。