D. Weird Chess

time limit per test

memory limit per test

input

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.

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.

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)

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

n (1 ≤ n ≤ 50).

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)
  • x — in this case field (i,j)
  • . — in this case field (i,j)

It is guaranteed that there is at least one piece on the board.

Output

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.

NO'.

Sample test(s)

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.


把能取的攻击范围尽量取上,最后看是否和原图一样



#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#include<cctype>
#include<ctime>
#include<vector>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Lson (x<<1)
#define Rson ((x<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define MAXN (100+10)
#define MP make_pair
long long mul(long long a,long long b){return (a*b)%F;}
long long add(long long a,long long b){return (a+b)%F;}
long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;}
typedef long long ll;
int n;
char s[MAXN];
int a[MAXN][MAXN];
bool b[MAXN][MAXN]={0};
int d[MAXN][MAXN];
vector<pair<int,int> > v;
int &cx=n,&cy=n;
int main()
{
// freopen("d.in","r",stdin);
// freopen(".out","w",stdout);

cin>>n;
For(i,n)
{
scanf("%s",s+1);
For(j,n)
{
switch (s[j])
{
case'o':a[i][j]=2; v.push_back(MP(i,j)) ; break;
case'x':a[i][j]=1 ; break;
case'.':a[i][j]=0 ; break;
}
}
}
d[cx][cy]=2;
For(i,2*n-1)
For(j,2*n-1)
{
if (i==cx&&j==cy) continue;
int dx=i-cx,dy=j-cy;
bool flag=1;
for(vector<pair<int,int> >::iterator it=v.begin();it!=v.end();it++)
{
int x=it->first,y=it->second;
if (1<=x+dx&&x+dx<=n&&1<=y+dy&&y+dy<=n)
if (!a[x+dx][y+dy])
{
flag=0;
break;
}
}

d[i][j]=flag;

}

For(i,2*n-1)
For(j,2*n-1)
{
if (i==cx&&j==cy) continue;
if (!d[i][j]) continue;
int dx=i-cx,dy=j-cy;
for(vector<pair<int,int> >::iterator it=v.begin();it!=v.end();it++)
{
int x=it->first,y=it->second;
if (1<=x+dx&&x+dx<=n&&1<=y+dy&&y+dy<=n)
b[x+dx][y+dy]=1;

}
}

For(i,n)
For(j,n)
if (a[i][j]!=2)
if (b[i][j]^a[i][j])
{
cout<<"NO"<<endl;
return 0;
}


cout<<"YES"<<endl;
For(i,2*n-1)
{
For(j,2*n-1)
switch (d[i][j])
{
case 0 :putchar('.');break;
case 1 :putchar('x');break;
case 2 :putchar('o');break;

}
putchar('\n');
}




return 0;
}