407413: GYM102785 I Noughts and crosses

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Noughts and crossestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

There are many options for playing noughts and crosses. Let's consider one of them.

A number of crosses and noughts are placed on the checkered square board, and there are some empty cells left. The player must fill in the empty squares so that neither crosses nor noughts form lines of more than three identical signs in a row. Lines are counted horizontally, vertically, or of diagonally format.

Your task will be to write a program which, in a given initial field, fills all empty cells with crosses or noughts according to the rules described above. If there are several such arrangements, then any of them will be considered correct.

It is guaranteed that for the input data, there is at least one correct solution.

Input

The first line of the input file contains number $$$n$$$ — the size of the board $$$(3 < n \le 20)$$$. This is followed by $$$n$$$ strings of $$$n$$$ characters in each — the initial state of the playing field. The cross is indicated by a «+» (plus) sign, a nought is indicated by a «0» (zero) symbol, an empty field is indicated by a «.» (dot) symbol.

Output

The output format is identical to the input data format (including board size). The solution should not contain empty fields.

ExampleInput
4
0.0.
00+0
0+00
++..
Output
4
0+00
00+0
0+00
++0+

加入题单

算法标签: