include[HTML_REMOVED]
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
const int N=10;
int hang[N];
int lie[N];
int xier[2N];
int xiel[2N];
int n;
char path[N][N];
void dfs(int u)
{
if(u>n)
{
for(int i = 1; i <= n; i)
{
for(int j = 1; j <= n; j)
cout << path[i][j];
cout << endl;
}
cout << endl;
return;
}
else
{
for(int i=1;i<=n;i)
{
if(!lie[i]&&!xier[i+u]&&!xiel[n-i+u])
{
lie[i]=xier[i+u]=xiel[n-i+u]=1;
path[u][i]=’Q’;
dfs(u+1);
lie[i]=xier[i+u]=xiel[n-i+u]=0;
path[u][i]=’.’;
}
}
}
}
int main()
{
cin>>n;
for (int i = 1; i <= n; i )
for (int j = 1; j <= n; j ++ )
path[i][j] = ‘.’;
dfs(1);
}