eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Triangular Tiling

Triangular Tiling

Triangular domino is a rhombic figure composed of two equilateral triangles. \includegraphics{https://static.e-olymp.com/content/56/5623fb34c52ba66d407cab6fe7eb160cca8d9e8d.jpg} Similarly triangular trimino is a trapezoid composed of three equilateral triangles. \includegraphics{https://static.e-olymp.com/content/eb/eb8a5aef05f4026334d2949751f128f566aeddd4.jpg} Consider a connected area on a triangular grid composed of unit triangles. You have to detect whether it is possible to tile the area with triangular dominoes and triminoes. Each triangle must be covered by exactly one tiling piece. \includegraphics{https://static.e-olymp.com/content/b9/b95efe23c9d7ffe958992357d0c35b8f1d06ef79.jpg} \InputFile The first line of the input file contains \textbf{n} - the number of triangles in the area (\textbf{1} ≤ \textbf{n} ≤ \textbf{500}). The following \textbf{n} lines contain coordinates of the triangles. The coordinates are assigned to the triangles as shown on the following picture. Coordinates do not exceed \textbf{500} by their absolute values. \includegraphics{https://static.e-olymp.com/content/aa/aa9cff9981a9f7b7651655e5854352d20137bdb4.jpg} \OutputFile If the tiling is impossible, output "\textbf{No solution}" at the first line of the output file. In the other case the first line of the output file must contain \textbf{k} - the number of pieces used. Let the pieces be numbered from \textbf{1} to \textbf{k}, the second line must contain \textbf{n} integer numbers, for each triangle of the given area output the number of the piece that it is covered by.
Лимит времени 1 секунда
Лимит использования памяти 256 MiB
Входные данные #1
15
0 0
1 0
2 0
0 1
1 1
2 1
3 1
4 1
-1 2
0 2
1 2
2 2
-2 3
-3 3
-4 3
Выходные данные #1
6
1 1 1 2 2 3 3 3 4 4 5 5 6 6 6
Автор Andrew Stankevich
Источник Andrew Stankevich Contest 32, Petrozavodsk Summer Training Camp, Wednesday, September 3, 2008