F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Last Problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1027    Accepted Submission(s): 469
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.
 

Sample Input
4
 

Sample Output
0 0 1 1 0 1 0 1 2 1 1 3 1 -1 2 1 0 4
 

Hint
1st 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
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 01:51:58, Gzip enabled