#P6677. [COCI 2019/2020 #2] Checker
[COCI 2019/2020 #2] Checker
Description
There is a regular polygon whose sides are colored using one of three colors, and its vertices are labeled from to in clockwise order.
A triangulation of the polygon means decomposing its area into a set of non-overlapping triangles, where the sides of these triangles can be polygon sides or interior diagonals. Of course, in this task, every diagonal used in the triangulation is also colored with one of the three colors.
Such a triangulation is called “very good” if, for each of the triangles, all three of its sides have different colors.
Your task is to determine whether the given polygon with its diagonals is correctly triangulated, and whether that triangulation is very good.
Input Format
The input has lines.
The first line contains a positive integer , which indicates the Subtask number for this test.
The second line contains a positive integer , as described in the Description section.
The third line contains a positive integer with digits. These digits represent the colors of the polygon sides. More precisely, the first digit represents the color of side , the second digit represents the color of side , the -th digit represents the color of side , and in particular, the -th digit represents the color of side . Colors are denoted by digits .
The next lines each contain a description of a diagonal in the format x y c, where and are polygon vertices, and is the color of the diagonal. The input guarantees that vertices and are neither equal nor adjacent.
Output Format
Output one line.
- If the input polygon is not correctly triangulated, output .
- If the input polygon has a correct triangulation, but the triangulation is not good, output .
- Otherwise, output .
1
5
12113
1 3 3
2 5 2
neispravna triangulacija
1
4
1212
1 3 2
neispravno bojenje
1
7
1223121
1 3 3
3 5 1
5 7 3
7 3 2
tocno
Hint
Constraints and Notes
This problem uses bundled tests.
| Subtask Number | Subtask Score | Constraints and Notes |
|---|---|---|
| , the testdata guarantees the output is or | ||
| , the testdata guarantees the output is or | ||
In particular, for of the testdata, .
Notes
The scoring of this problem follows the original COCI problem setting, with a total of points.
Translated from COCI2019-2020 CONTEST #2 T3 Checker.
Translated by ChatGPT 5
京公网安备 11011102002149号