-
Notifications
You must be signed in to change notification settings - Fork 8
/
cbaq.cpp
45 lines (40 loc) · 848 Bytes
/
cbaq.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
// Header Files and namespaces
// #include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;
// Code Shortners
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define endl '\n'
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
char chess[8][8];
int c=0;
bool ld[15],rd[15],row[7];
void rec(int j){
if (j==8){
c++; return;
}
for(int i=0;i<8;i++){
if(chess[i][j]=='.' && ld[i-j+7]==0 && rd[i+j]==0 && row[i]==0){
ld[i-j+7]=1; rd[i+j]=1; row[i]=1;
rec(j+1);
ld[i-j+7]=0; rd[i+j]=0; row[i]=0;
}
}
}
// Code
int main()
{
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
cin>>chess[i][j];
}
}
rec(0);
cout<<c;
return 0;
}