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

Totem

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

의견: 0

설명

\(5^{th}\) round, February \(16^{th}\), 2013
Authors: Nikola Dmitrović, Antun Razum

Mister No (real name Jerry Drake) is a comic book character who frequently gets himself into a lot of
trouble, which he is usually able to get out of. However, this time it's not so easy. He was searching for
ancient Mayan treasures and, in the process, stumbled upon a lost temple. Inside the temple there is a
large hall, and inside the hall stands a stone Totem with inscriptions that are the key to understanding
the purpose of life (42). However, getting to the Totem is a great challenge.
The Totem is situated on the opposite side of the hall form the entrance. The floor of the hall is
covered with stone tiles that bear a striking resemblance to domino tiles. Each tile is divided into two
halves (squares), and each half has a number from one to six, inclusive, chiseled into it. Tiles are
arranged in N rows, with N tiles in each o\(dd-nu\)mbered row and \(N - 1\) tiles in each ev\(en-nu\)mbered
row. The image below corresponds to the first test example (\(N = 5\)):

It is only possible to step from one tile to an adjacent one if the two tiles have matching numbers on
halves that share an edge. Help Mister No find the shortest path to the Totem by determining the
sequence of tiles (outputting the sequence of tiles' labels, described below) that need to be stepped on,
in order, from the first to the last tile on the path. If there is no possible path to the Totem, find the
shortest path to the tile with the largest label (so that Mister No can make a heroic jump). The stone
tiles are labelled in r\(ow-ma\)jor order: in the first row, the first tile has the label 1, and the last one N; in
the second row, the first tile is \(N + 1\), and the last one \(2*N - 1\), and so on. The entrance leads to the
tile with label 1, and the totem is on the last tile in the last row. Mister No always starts from the
entrance.

제약

If only the first line of output is correct, the solution is awarded 50% of points for that test case.

입력 형식

The first line of input contains the positive integer N (\(1 \le N \le 500\)), the number of stone tile rows.
Each of the following \(N * N - N / 2\) lines (where “/” stands for integer division) contains two positive
integers A_{i} and B_{i} (\(1 \le A_{i}\), \(B_{i} \le 6\), \(1 \le i \le N * N - N / 2\)), the values chiseled into the left and right
halves, respectively, of tile i.

출력 형식

The first line of output must contain the length (in tiles) of the required shortest path.
The second line of output must contain a sequence of spa\(ce-se\)parated positive integers, the labels of
tiles on the shortest path. As there can exist more than one shortest path, output any one of them.
\(5^{th}\) round, February \(16^{th}\), 2013
Authors: Nikola Dmitrović, Antun Razum

예제 1
입력
5
1 4
4 5
3 4
5 4
5 2
4 2
5 6
4 4
6 5
2 4
5 1
6 1
1 6
2 3
4 2
5 3
1 2
5 5
4 1
2 2
4 3
2 3
3 4
출력
7
1 2 7 12 17 22 23
예제 2
입력
3
1 2
2 3
6 6
2 4
3 5
6 6
4 5
5 6
출력
4
1 2 5 8
예제 3
입력
4
1 5
5 3
5 5
5 6
5 3
6 4
4 5
2 5
2 4
4 3
2 4
5 2
1 4
1 6
출력
7
1 5 8 12 9 10 13
문제 정보

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

출처 COCI 2012/2013 Contest 5

평가 및 의견

Totem

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

Log in to rate problems.

개별 의견

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

풀이 제출

Totem

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