n = int(input())
dg, ndg, col_unused = [True] * (n<<1) , [True] * (n<<1), [True] * n
row = [-1] * n
def dfs(k):
if k == n:
[print('.'*i + 'Q' + '.' * (n - i - 1)) for i in row] + [print('')]
return
for i in range(n):
if col_unused[i] and dg[i + k] and ndg[n + i - k]:
row[k] = i
col_unused[i] = dg[i + k] = ndg[n + i - k] = False
dfs(k + 1)
col_unused[i] = dg[i + k] = ndg[n + i - k] = True
dfs(0)
给跪了
膜拜,天啊
膜拜
老哥你这python写的牛逼
老哥这python写得6⃣️