QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 10

#10378. Rooks [B]

统计

After quite a lot of effort Bytie has finally managed to put $ n $ rooks on a board of size $ n $ × $ n $ so that no two of them attack each other. A quick reminder: a rook attacks all the fields of the board that are located in the same row or in the same column as it is^{1}.

Unfortunately, the boy has now accidentally hit the board. As a result, several rooks have fallen down from it. Could you help Bytie put these rooks back on the board? The boy would like to leave the rooks that are still on the board intact.

  1. See also http://en.wikipedia.org/wiki/Rook_(chess))

Input Format

The first line of the standard input contains one integer $ n $ ($2 \le n \le 1\,000$) that represents the size of the board. A description of the configuration of the rooks follows: the following $ n $ lines contain $ n $ characters each. The character '.' represents an empty field whereas the letter 'W' represents a field occupied by a rook.

You can assume that there are $ w $ rooks on the board with $1 \le w \le n-1$ and that no pair of rooks on the board attacks each other.

Output Format

Your program should write to the standard output $ n $ lines containing $ n $ characters '.' or 'W' each: the final configuration of rooks on the board. The description should contain exactly $ n $ occurrences of the letter 'W' with $ w $ rooks placed in the same positions as in the initial board. No two rooks may attack each other. If there are multiple ways of placing $ n - w $ rooks on the initial board, your program should output any one of them.

Example

Input

8
........
.....W..
..W.....
.......W
W.......
........
.W......
........

Output

...W....
.....W..
..W.....
.......W
W.......
....W...
.W......
......W.

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.