#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dd double
#define LL __int128
using namespace std;
ll read()
{
char c;
ll w = 1;
while((c = getchar()) > '9' || c < '0')
if(c == '-') w = -1;
ll ans = c - '0';
while((c = getchar()) >= '0' && c <= '9')
ans = (ans << 1) + (ans << 3) + c - '0';
return ans * w;
}
void pc(char c,int op)
{
static char buf[1 << 16],*s = buf,*t = (buf + (1 << 16));
(op || ((*s ++= c) && (s == t))) && (fwrite(buf,1,s - buf,stdout),s = buf);
}
void wt(int x)
{
if(x > 9) wt(x / 10);
pc('0' + x % 10,0);
}
void wts(int x,char op)
{
if(x < 0) pc('-',0),x = -x;
wt(x),pc(op,0);
}
const int N = 15;
int n;
int row_valid[N];
char a[N][N];
int ans;
void dfs(int row,int col_ban,int diag_ban_l,int diag_ban_r)
{
if(row == n)
{
ans++;
return ;
}
int tmp_valid = row_valid[row] & ~(col_ban | diag_ban_l | diag_ban_r);
for(int i = 1; i <= n; ++i)
{
if(tmp_valid >> i & 1)
{
dfs(row + 1, col_ban | (1 << i),
(diag_ban_l | (1 << i)) << i,
(diag_ban_r | (1 << i)) >> 1);
}
}
}
signed main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
n = read();
for(int i = 1; i <= n; ++i)
{
cin >> a[i];
for(int j = 1; j <= n; ++j)
if(a[i][j] == '.')
row_valid[i] |= 1 << j;
}
dfs(0,0,0,1);
printf("%d\n",ans);
return 0;
}
为什么只有10pts?