5247: 奇怪的国际象棋

内存限制:256 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

D. 奇怪的国际象棋
每次测试的时间限制
2 秒
每个测试的内存限制
256 兆字节
输入
标准输入
输出
标准输出
伊戈尔已经下国际象棋很长时间了,现在他厌倦了普通规则的游戏。他将思考新的游戏规则并成为世界闻名。
伊戈尔的棋盘是一个大小为 n×n 个单元格的正方形。伊戈尔认为简单的规则可以保证成功,这就是为什么他的游戏只有一种类型的棋子。此外,他游戏中的所有棋子都是相同的颜色。一块可能的移动由一组移位向量描述。下一段包含对可用移动的正式描述。
让板的行从上到下编号,列从左到右从 1 到 n 编号。让我们为每个正方形分配一对整数 xy− 相应列和行的数量。棋子的每个可能的移动都由一对整数 dxdy 定义;使用此移动,棋子从字段 xy 移动到字段 x+dxy+dy)。如果单元格 x+dxy+dy 在棋盘的边界内并且不包含其他棋子,则可以执行移动。在考虑进行给定移动的可能性时(例如,当骑士在通常的国际象棋中移动时),站在xy)和(x+dxy+dy以外的单元格上的棋子并不重要。
伊戈尔为您提供了解他的棋子可以做出的动作。他在棋盘上放了几块棋子,对于每个未被占用的方块,他会告诉你它是否受到任何当前棋子的攻击(即场上的一些棋子是否可以移动到该单元)。恢复该片的一组可能的移位向量,或者确定 Igor 犯了一个错误,并且这种情况对于任何一组移位向量都是不可能的。

输入
第一行包含单个整数 n (1≤n≤50)。
接下来的n行包含n个字符,每个字符描述Igor提供的位置。第 i 个字符串的第 j 个字符可以具有以下值:

  • o − 在这种情况下,字段 ij 被一个片段占用,该字段可能会也可能不会被其他某个片段攻击;
  • 在这种情况下,x − 字段 ij 被某个片段攻击;
  • .− 在这种情况下,字段 ij 不会受到任何片段的攻击。
保证板上至少有一块。
输出
如果有一组有效的移动,请在第一行打印一个单词“YES”(不带引号)。接下来,以 (2n-1)×(2n-1 板的形式打印一块棋子的一组移动的描述,棋盘的中心有一块棋子和符号“x”标记被它攻击的单元格,格式类似于输入。请参阅输出示例以全面了解格式。如果有多个可能的答案,请打印其中任何一个。
如果一组有效的移动不存在,请打印单个单词“NO”。

例子
输入
5
oxxxx
x...x
x...x
x...x
xxxxo
输出
YES
....x....
....x....
....x....
....x....
xxxxoxxxx
....x....
....x....
....x....
....x....
输入
6
.x.x..
x.x.x.
.xo..x
x..ox.
.x.x.x
..x.x.
输出
YES
...........
...........
...........
....x.x....
...x...x...
.....o.....
...x...x...
....x.x....
...........
...........
...........
输入
3
o.x
oxx
o.x
输出
NO
注意
在第一次样本测试中,棋子是普通的国际象棋车,在第二次样本测试中,棋子是普通的国际象棋骑士。
D. Weird Chess
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Igor has been into chess for a long time and now he is sick of the game by the ordinary rules. He is going to think of new rules of the game and become world famous.
Igor's chessboard is a square of size n×n cells. Igor decided that simple rules guarantee success, that's why his game will have only one type of pieces. Besides, all pieces in his game are of the same color. The possible moves of a piece are described by a set of shift vectors. The next passage contains a formal description of available moves.
Let the rows of the board be numbered from top to bottom and the columns be numbered from left to right from 1 to n. Let's assign to each square a pair of integers (x,y)− the number of the corresponding column and row. Each of the possible moves of the piece is defined by a pair of integers (dx,dy); using this move, the piece moves from the field (x,y) to the field (x+dx,y+dy). You can perform the move if the cell (x+dx,y+dy) is within the boundaries of the board and doesn't contain another piece. Pieces that stand on the cells other than (x,y) and (x+dx,y+dy) are not important when considering the possibility of making the given move (for example, like when a knight moves in usual chess).
Igor offers you to find out what moves his chess piece can make. He placed several pieces on the board and for each unoccupied square he told you whether it is attacked by any present piece (i.e. whether some of the pieces on the field can move to that cell). Restore a possible set of shift vectors of the piece, or else determine that Igor has made a mistake and such situation is impossible for any set of shift vectors.

Input
The first line contains a single integer n (1≤n≤50).
The next n lines contain n characters each describing the position offered by Igor. The j-th character of the i-th string can have the following values:

  • o − in this case the field (i,j) is occupied by a piece and the field may or may not be attacked by some other piece;
  • x − in this case field (i,j) is attacked by some piece;
  • . − in this case field (i,j) isn't attacked by any piece.
It is guaranteed that there is at least one piece on the board.
Output
If there is a valid set of moves, in the first line print a single word 'YES' (without the quotes). Next, print the description of the set of moves of a piece in the form of a (2n-1)×(2n-1) board, the center of the board has a piece and symbols 'x' mark cells that are attacked by it, in a format similar to the input. See examples of the output for a full understanding of the format. If there are several possible answers, print any of them.
If a valid set of moves does not exist, print a single word 'NO'.

Examples
Input
5
oxxxx
x...x
x...x
x...x
xxxxo
Output
YES
....x....
....x....
....x....
....x....
xxxxoxxxx
....x....
....x....
....x....
....x....
Input
6
.x.x..
x.x.x.
.xo..x
x..ox.
.x.x.x
..x.x.
Output
YES
...........
...........
...........
....x.x....
...x...x...
.....o.....
...x...x...
....x.x....
...........
...........
...........
Input
3
o.x
oxx
o.x
Output
NO
Note
In the first sample test the piece is a usual chess rook, and in the second sample test the piece is a usual chess knight.

输入样例 复制


输出样例 复制