CSES - Shared codeLink to this code: https://cses.fi/paste/b9dfd29f5d38a986462bf9/
#include<iostream>
#include<vector>
using namespace std;
int sol=0;
vector<vector<bool>> board(8,vector<bool>(8,1));
vector<bool> column(8,0), diag1(16,0), diag2(16,0);
void solve(int row){
    if(row==8){
        sol++;
        return;
    }
    for(int i=0;i<8;i++){
        if(column[i]||diag1[row+i]||diag2[row-i+7]) continue;
        if(!board[row][i]) continue;
        column[i]=1;
        diag1[row+i]=1;
        diag2[row-i+7]=1;
        solve(row+1);
        column[i]=diag1[row+i]=diag2[row-i+7]=0;
    }
}
int main(){
    string s;
    for(int i=0;i<8;i++){
        cin>>s;
        for(int j=0;j<8;j++) {
            if(s[j]=='*') board[i][j]=0;
        }

    }
    solve(0);
    cout<<sol<<"\n";
}