RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00530

Trobojnica

Unrated 레이팅 미적용
난이도
2s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

„Everything will \(be\) \(in\) flames once red, white and blue start running through your veins” – Slaven Bilić
In this task, we will observe regular polygons that have each of their \(N\) sides colored in one of three
colors and whose vertices are denoted from 1 to \(N\) in a clockwise order. A triangulaton of a polygon
is a decomposition of its area into a set of n\(on-ov\)erlapping triangles whose sides either lie on the sides
of the polygon or its internal diagonals. Of course, in this task, each of the diagonals used for polygon
triangulation is also colored in one of three colors.
The triangulation is said to be patriotic if each of its \(N - 2\) triangles has all three sides of different colors.
Your task is to determine a patriotic triangulation of a given polygon.

제약

Subtask
Score
Constraints
1
20
\(4 \le N \le 11\)
2
40
\(4 \le N \le 10^{3}\)
3
50
\(4 \le N \le 2 \cdot 10^{5}\)
If your program correctly outputs the first line in each test case of a certain subtask, you will score 10%
of the points allocated for that subtask.

입력 형식

The first line contains an integer \(N\) from the task description.
The second line contains an integer consisting of \(N\) digits which represent the colors of polygon sides.
More precisely, the first digit represents the color of side (1, 2), the second digit represents the color of
side (2, 3), and so on until the \(N-th\) digit which represents the color of side (N, 1). The colors will always
be denoted with digits 1, 2 and 3.

출력 형식

If there is no patriotic triangulation of the given polygon, output NE and terminate the program. Otherwise,
in the first line output DA and in the next \(N - 3\) lines output each diagonal used in the patriotic triangulation.
Each diagonal should be specified as \(X\) \(Y\) \(C\) where \(X\) and \(Y\) are the endpoints of a diagonal and \(C\) is its
color (\(1 \le X\), \(Y \le N\), \(1 \le C \le 3\)). The order of diagonals in the output is not important. If there are
multiple correct solutions, output any of them.

예제 1
입력
4
1212
출력
DA
1 3 3
예제 2
입력
4
1213
출력
NE
예제 3
입력
7
1223121
출력
DA
1 3 3
3 5 1
5 7 3
7 3 2
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2019/2020 Contest 1

평가 및 의견

Trobojnica

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Trobojnica

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8