@[yuyjcode](/user/1126325) 代码?只给个记录没人看得到。
by xiaoshumiao @ 2024-01-24 19:37:39
@[xiaoshumiao](https://www.luogu.com.cn/user/1008513)
```cpp
#include<bits/stdc++.h>
using namespace std;
const int SIZE=150;
int n,ans[SIZE],counted;
bool s[SIZE][SIZE];
char k[SIZE][SIZE];
bool check(int x,int y){
if (k[x-1][y-1]=='.') return 0;
for (int i=1;i<=n;i++)
if (s[i][y]) return 0;
for (int i=max(1-x,1-y);i<=max(n-x,n-y);i++)
if (i && s[x+i][y+i]) return 0;
for (int i=1,j=x+y-1;j;i++,j--)
if (i!=x && s[i][j]) return 0;
return 1;
}
void dfs(int t){
if (t>=n){
counted++;
return;
}
t++;
for (int i=1;i<=n;i++){
if (check(t,i)){
ans[t]=i,s[t][i]=1;
dfs(t);
ans[t]=0,s[t][i]=0;
}
}
}
int main(){
scanf("%d",&n);
for (int i=0;i<n;i++) scanf("%s",k[i]);
dfs(0);
printf("%d",counted);
return 0;
}
```
by I_like_play_eggy @ 2024-01-26 19:05:57
@[xiaoshumiao](/user/1008513) 上面回复错了,上面是个超链接
by I_like_play_eggy @ 2024-01-30 15:40:18
@[yuyjcode](/user/1126325) 你这不是在用DFS做吗?这题数据范围太大了不能搜索
by oxygen_minister @ 2024-01-31 19:34:27