HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Fyodor Menshikov. Training > problem:


03F. 50616 - Snake

Guest
• Review clarifications (1)

Volume problems

• 04F. 50636 - Brackets
• 01A. 50650 - Prime numbers
• 01E. 50661 - nth Power of a Digit
• 02B. 50625 - Permutations
• 02C. 50626 - The route
• 02F. 50647 - Spiral
• 03A. 50633 - The prime factors
• 03B. 50720 - Permutations (2)
• 03F. 50616 - Snake
• 01B. 50600 - Expression
• 01C. 50601 - Increasing sequence
• 01D. 50660 - Triangle and the point
• 02A. 50662 - Prime numbers (2)
• 02E. 50607 - Long sum
• 03D. 50666 - The card and envelope
• 03E. 50606 - Long product
• 04A. 50634 - Perfect numbers

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Автор: Фёдор Меньшиков, ВГПУ.

Snake

Russian
Draw a square from NxN cells filled with numbers from 1 to N2 in the shape of "Snake" (see examples below).
Input
The first line contains a single number N.
Output
Print N lines of N numbers, separated by spaces. It's not allowed beginning snake from another corner or another direction.

Restrictions
2 ≤ N ≤ 100.

Input 1 Input 2 Input 3
3
4
5
Output 1 Output 2 Output 3
1 2 6
3 5 7
4 8 9
 1  2  6  7
 3  5  8 13
 4  9 12 14
10 11 15 16
 1  2  6  7 15
 3  5  8 14 16
 4  9 13 17 22
10 12 18 21 23
11 19 20 24 25

Для отправки решений необходимо выполнить вход.

www.contester.ru