|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||4||3||3||75.000%|
Marika is developing a game called “Minegraphed” that involves moving around a 3D rectangular world.
Each cell of a parallelepiped game field is either an empty cell or an obstacle cell. You are always standing inside an empty cell, located either in the bottommost layer or on top of an obstacle cell. Each move can be made in one of four directions: north, east, south, or west. You make a move according to these rules:
Marika prepared a directed graph with n vertices. Now she wants to lay out the field and label n different possible standing positions with numbers from 1 to n, so that it is possible to get from the cell labeled i to the cell labeled j by making valid moves if and only if in Marika’s graph it is possible to get from vertex i to vertex j along the edges of the graph. Help Marika design a field satisfying this property.
The first line contains a single integer n (1 ≤ n ≤ 9) — the number of vertices. Each of the next n lines contains n integers equal to 0 or 1. The j-th number in the i-th line is 1 if there is an edge from vertex i to vertex j and 0 otherwise. The i-th number in the i-th line is always zero.
Output a layer-by-layer description of a field that has the same reachability as the given graph.
The first line should contain three positive integers x, y, and z, the west-east, north-south, and top-bottom sizes of the designed parallelepiped. Blocks describing z layers should follow, from the topmost layer to the bottommost layer, separated by single empty lines. Each block should contain y lines of length x, consisting of dots (‘.’), hashes (‘#’), and digits from 1 to n. A hash denotes an obstacle cell. A dot denotes an unlabeled empty cell. A digit denotes a labeled empty cell. Each digit from 1 to n should appear exactly once. Each digit should be located either in the bottommost layer or on top of an obstacle cell. It is okay for obstacles to be “hanging in the air” (there is no gravity for them).
The volume of the field x×y ×z should not exceed 106 . It is guaranteed that there is a correct field fitting into this limit for any possible graph in the input.
4 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 0
4 2 3 ..#. .4.. #### 1#.# ..3. #2..
Note that you can climb up from cell 1 to cell 4, but you cannot climb up from cell 2 to cell 1 because of a “ceiling” obstacle.