Last Problem

TimeLimit:1000MS  MemoryLimit:524288KB
64-bit integer IO format:%I64d
Special Judge
未提交 | 登录后收藏
Problem Description
It's the night before Zhang3's birthday, and she's preparing for her birthday party in the classroom. She has brought a huge birthday cake and some powerful tomatoes, and has decorated almost every corner of the classroom. However, the blackboard is still empty. The last thing to do is to draw a beautiful pattern on it.

The blackboard is regarded as an infinite plane, each integer point $(x, y)$ has an integer value as its color. At the very beginning, the color of every point is $0$.

Zhang3 has $n$ crayons, labeled $1, 2, \ldots, n$. Painting with the $i ^ \mathrm{th}$ crayon, you can replace the color of some chosen integer point $(x, y)$ with color $i$. It is called a step, and she will draw the pattern step by step.

According to Zhang3's judgement of beautiful patterns, there's a restriction: Just before you paint $(x, y)$ into some color $i$, the last four colors of $i$ must appear among the adjacent points of $(x, y)$. The last four colors of $i$ means colors from $(i - 4)$ to $(i - 1)$, ignoring those non-positive ones. Two integer points are adjacent if their Euclid distance is exactly one. (Note that a point is not adjacent to itself.) If the condition above is not satisfied, the step is not allowed.

Zhang3 doesn't want to waste crayons, so the final pattern should contain at least one point with color $n$. Please help her find a way to draw such a beautiful pattern.
Input
The only line of the input contains an integer $n \; (1 \le n \le 100)$, the number of crayons.
Output
Print the steps in chronological order, each in a separate line. Notice that you should not print the number of steps.

In the $i ^ \mathrm{th}$ line, print three integers $x_i, y_i, c_i$, separated by spaces, indicating the $i ^ \mathrm{th}$ step is to paint $(x_i, y_i)$ into color $c_i$.

Your answer should satisfy $|x_i|, |y_i| \le 10^9, \; 1 \le c_i \le n$. The number of steps should not exceed $10^5$. The output file should not be larger than $5 \; \text{MB}$.

It can be proved that there is always a solution. Any solution that meets all of the requirements will be accepted.
SampleInput
4
SampleOutput
0 0 1
1 0 1
0 1 2
1 1 3
1 -1 2
1 0 4

 Hint1st step: paint (0, 0) into color 1. 000 010 000 2nd step: paint (1, 0) into color 1. 0000 0110 0000 3rd step: paint (0, 1) into color 2. 0000 0200 0110 0000 4th step: paint (1, 1) into color 3. 0000 0230 0110 0000 5th step: paint (1, -1) into color 2. 0000 0230 0110 0020 0000 6th step: paint (1, 0) into color 4. 0000 0230 0140 0020 0000
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: