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

Zlagalica

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

의견: 0

설명

Little Maja has always loved puzzles. And since everyone knew that for a long
time now, it is no wonder that one sunny day, Maja received an odd puzzle as a
gift..
This puzzle has \(n\) pieces. Each piece has rectangular shape and is of a certain
color. Also, each piece has 2 numbers written on its back: \(u\) and \(d\). After a period
of skillfully combining pieces and trying to fit them together, Maja figured out the
meaning of those numbers.
She found out that number \(u\) represents "direction", in other words, does the next piece of the pu-
zzle connect with the current one from the upper or from the right side of the current piece. Number
\(d\) specifies the starting colu\(mn/ro\)w where we connect the next piece of the puzzle with current one. In
more detail:
• If \(u\) is equal to 0, we add next piece above the current one by connecting its bottom left corner
with current piece’s top edge at column d.
• If \(u\) is equal to 1, we add next piece to the right by connecting its bottom left corner with current
piece’s right edge at row d.
Let’s demonstrate this for pieces colored in colors "a" and "b". Picture 1 shows the case where \(u = 0\), and
\(d = 3\). Picture 2 shows case when \(u = 1\) and \(d = 3\). (In both cases, numbers \(u\) and \(d\) represent numbers
written on the back of piece colored "a").
Picture 1
Picture 2
Maja has grown tired of this puzzling puzzle, but her curiosity knows no bounds! That’s why she’s asking
for your help. She’s interested in knowing, for a given description of every piece of the puzzle and the
sequence of their placement, what will the completed puzzle look like? Write a program that prints the
dimensions (height and width) of the completed puzzle, as well as its final appearance within a rectangle
of the same height and width, where "." represents places where there is no part of the puzzle.

제약

Subtask 1 (17 points): The order of connecting the puzzle pieces will be identical to the order of inputting them.

Subtask 2 (12 points): For each puzzle piece: \(u = 0\).

Subtask 3 (12 points): For each puzzle piece: \(u = 1\).

Subtask 4 (9 points): No additional constraints.

입력 형식

In first row, there is \(n\) (\(1 \le n \le 20\)), number of puzzle pieces.
In the \(i-th\) of next \(n\) rows there are per 1 character and 4 integers, in order: \(b_{i}\), r_{i}, s_{i}, u_{i}, \(d_{i} - de\)scription of
\(i-th\) piece:
\(b_{i}\) will always be 1 lowercase letter of english alphabet, and it represents the color of the \(i-th\) puzzle
piece
\(r_{i}\) and \(s_{i}\) (\(1 \le r_{i}\), \(s_{i} \le 10\)) represent in order, number of rows and columns of \(i-th\) puzzle piece
\(u_{i}\) and \(d_{i}\) (\(0 \le u_{i} \le 1\), \(1 \le d_{i} \le r_{i}\), s_{i} (depends on \(u_{i}\))) are numbers on the back of \(i-th\) puzzle piece,
same as in the task statement.
In the last row of input there are \(n\) integers, order in which pieces are connected, where number \(i\)
(\(1 \le i \le n\)) represents \(i-th\) puzzle piece in input. Each puzzle piece will appear in the sequence exactly
once.

출력 형식

Print the height and width of the completed puzzle. After that, print the appearance of the puzzle within
a rectangle of the same height and width. In the places within the rectangle where there is no part of the
puzzle, print ".".

서브태스크
서브태스크점수설명

1

17점

The order of connecting the puzzle pieces will be identical to the order of inputting them.

2

12점

For each puzzle piece: \(u = 0\).

3

12점

For each puzzle piece: \(u = 1\).

4

9점

No additional constraints.

예제 1
입력
2
a 3 4 0 3
b 2 5 1 1
1 2
출력
5 7
..bbbbb
..bbbbb
aaaa...
aaaa...
aaaa...
예제 2
입력
2
a 3 4 0 3
b 2 5 1 1
2 1
출력
4 9
.....aaaa
.....aaaa
bbbbbaaaa
bbbbb....
예제 3
입력
4
g 9 5 0 2
a 3 2 1 1
c 5 10 0 2
p 8 7 1 6
4 3 2 1
출력
18 17
..........ggggg..
..........ggggg..
..........ggggg..
..........ggggg..
..........ggggg..
..........ggggg..
..........ggggg..
..........ggggg..
........aaggggg..
........aa.......
ppppppp.aa.......
pppppppcccccccccc
pppppppcccccccccc
pppppppcccccccccc
pppppppcccccccccc
pppppppcccccccccc
ppppppp..........
ppppppp..........
문제 정보

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

출처 COCI 2023/2024 Contest 5

평가 및 의견

Zlagalica

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

Log in to rate problems.

개별 의견

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

풀이 제출

Zlagalica

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