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

23487번 - Triangle Tiling 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 (추가 시간 없음) 1024 MB293150.000%

문제

Chiaki has an equilateral triangle with side length $n$. She would like to tile the triangle using unit rhombi with angles equal to 60ドル^\circ$and 120ドル^\circ$.

An equilateral triangle with side length 4ドル,ドル Three types of rhombus numbered from 1ドル$ to 3ドル$ from left to right.

Chiaki soon figures out it's an impossible task. So she cuts out exactly $n$ of the upward triangles from the equilateral triangle. Now, Chiaki would like to know whether it is possible to tile the remaining shape with rhombi. The figure below is an example tiling for $n=4$.

입력

There are multiple test cases. The first line of input contains an integer $T,ドル indicating the number of test cases. For each test case:

The first line contains an integer $n$ (1ドル \le n \le 5000$) -- the side length of the equilateral triangle.

The $i$-th line the following $n$ lines contains a binary string $s$ with length $i,ドル where $s_j=0$ means the $j$-th upward triangle was cut out.

It is guaranteed that the sum of $n$ over all test cases does not exceed 5000ドル$.

출력

For each test case, output a valid tiling. A valid tiling consists of $n$ lines and the $i$-th line contains $i$ characters. The $j$-th character should be:

  • '-': if the $j$-th upward triangle was cut out.
  • '1': if the $j$-th upward triangle was coverd by the first type rhombus.
  • '2': if the $j$-th upward triangle was coverd by the second type rhombus.
  • '3': if the $j$-th upward triangle was coverd by the third type rhombus.

If there is no solution, output "Impossible!" (without the quotes) instead.

제한

예제 입력 1

1
4
0
11
010
1101

예제 출력 1

-
21
-3-
33-1

힌트

출처

Contest > Open Cup > 2019/2020 Season > Stage 18: Grand Prix of Bytedance A번

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

출처

대학교 대회

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

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