-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11195.cpp
63 lines (57 loc) · 827 Bytes
/
11195.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
11195 - Another n-Queen Problem
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define M 1000007
int n;
string str[15];
int call(ll row,ll cur,ll left,ll right)
{
if(row==n)
return 1;
int ret=0;
ll all = cur|left|right;
for(int i=0; i<n; i++)
{
ll te=(1ll<<i);
if(str[row][i]=='.'&&!(te&all))
{
ret+=call(row+1,cur|te,(left|te)>>1,(right|te)<<1);
}
}
return ret;
}
int main()
{
int casee=1;
while(cin>>n &&n)
{
for(int i=0; i<n; i++)
cin>>str[i];
cout<<"Case "<<casee++<<": "<<call(0,0,0,0)<<endl;
}
return 0;
}
/*
Sample Input
8
........
........
........
........
........
........
........
........
4
.*..
....
....
....
0
Sample Output
Case 1: 92
Case 2: 1
*/