Logo
(追記) (追記ここまで)

14520번 - Trapezi 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.5 초 1024 MB67271446.667%

문제

We can create a hexagonal puzzle the size of n by dividing a regular hexagon into equilateral triangles by drawing 2n − 1 equidistant parallel lines between each three pairs of opposite hexagon sides. Some of the triangles in the puzzle are shaded and need to be covered with puzzle pieces. Each piece is a trapezoid that consists of three equilateral triangles placed side by side. The pieces come in 6 different colours denoted with numbers from 1 to 6, and we have an unlimited number of pieces of each colour at our disposal.

Slika 1: Puzzle of size 3 from the first sample and one solution.

The goal of the puzzle is to put the pieces on the hexagon so that the following holds:

  1. Each piece is placed so it fully covers three shaded triangles.
  2. Each shaded triangle is covered by exactly one piece.
  3. Two pieces of the same colour do not touch along the side of a triangle (they may touch in a corner).

Determine if it is possible to solve the given puzzle, and, if it is, find one solution.

입력

The first line of input contains the positive integer n — the size of the puzzle. The following 2n lines describe the rows of the puzzle from top to bottom. Each of these lines contains a string that describes the triangles in one row of the puzzle from left to right. The digit “0” denotes a shaded triangle, whereas “.” (dot) denotes a triangle that is not shaded. You can assume that at least one triange will be shaded.

출력

If the puzzle is impossible to solve, output in the first line “nemoguce” (Croatian for impossible). Otherwise, output 2n lines that describe the solution in the same format as the puzzle is given in the input. Shaded triangles should be denoted with one of the digits from “1” to “6”, instead of the digit “0”. The digits represent the colour of the pieces the triangle is covered with.

제한

서브태스크

번호배점제한
16

n = 1

217

n = 2

318

n = 3

422

n = 4

537

n = 5

예제 입력 1

3
.000000
...000000
.....000000
.....0.....
...000...
.00000.

예제 출력 1

.111224
...332442
.....311122
.....1.....
...112...
.33322.

예제 입력 2

1
.0.
0.0

예제 출력 2

nemoguce

예제 입력 3

2
0000.
0000000
..00.0.
.0000

예제 출력 3

1222.
1133111
..31.2.
.1122

힌트

출처

Olympiad > Croatian Highschool Competitions in Informatics > 2017 > Croatian Olympiad in Informatics 2017 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /