всем привет!!! Тут наткнулся на такую задачу короче вот фото : http://postimg.org/image/rxmpkfjwd/
как решать?
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | dXqwq | 3436 |
| 8 | Radewoosh | 3415 |
| 9 | Otomachi_Una | 3413 |
| 10 | Um_nik | 3376 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | adamant | 153 |
| 3 | Um_nik | 146 |
| 3 | Proof_by_QED | 146 |
| 5 | Dominater069 | 145 |
| 6 | errorgorn | 141 |
| 7 | cry | 139 |
| 8 | YuukiS | 135 |
| 9 | TheScrasse | 134 |
| 10 | chromate00 | 133 |
всем привет!!! Тут наткнулся на такую задачу короче вот фото : http://postimg.org/image/rxmpkfjwd/
как решать?
Здравствуйте дорогие пользователи Codeforces
Можете помочь мне с этой задачей?
Ссылка(http://mendo.mk/Task.do?id=211)

We shall name a square matrix as spiral123 if it has the following properties:
· its elements are from the {0, 1, 2, 3} set; - · each row and column contains each of the values 1, 2 and 3, exactly once and all the other values are 0;
· starting from the upper-left corner going right, moving in spiral, the non-zero values will appear in the
following order 1, 2, 3, 1, 2, 3, ... , 1, 2, 3.
For example a 5x5 spiral123 matrix is the following:
0 1 0 2 3
0 2 3 0 1
1 3 0 0 2
3 0 2 1 0
2 0 1 3 0
Task
For a given natural number n, you should generate a n x n spiral123 matrix.
Description of input
The spiral123.in file contains only one natural number n on the first line.
Description of output
If there is solution, the spiral123.out file must contain n lines, each with n numbers separated
with one
space, representing the required matrix. If there is no solution, on the single line of the
output file, the -1 value
will be written.
Constrains
· 5 < n < 200;
· There can be many solutions, any of them can be written.
Example
spiral123.in spiral123.out remarks
5
0 1 0 2 3
0 2 3 0 1
1 3 0 0 2
3 0 2 1 0
2 0 1 3 0
another correct solution would be:
0 1 2 3 0
2 3 0 0 1
0 0 3 1 2
1 0 0 2 3
3 2 1 0 0
Дорогие пользователи сайта codeforces я хотел изучить бинпоиск можете дать хороший материал?
Заранее благодарен!!!
| Название |
|---|


