6689.Chessboard and Queens

Time Limit: 1s Memory Limit: 512MB

Your task is to place eight queens on a chessboard so that no two queens are attacking each other. As an additional challenge, each square is either free or reserved, and you can only place queens on the free squares. However, the reserved squares do not prevent queens from attacking each other.

How many possible ways are there to place the queens?

Input Format(From the terminal/stdin)

The input has eight lines, and each of them has eight characters. Each square is either free (.) or reserved (*).

Output Format(To the terminal/stdout)

Print one integer: the number of ways you can place the queens.

Sample Input

Copy
........
........
..*.....
........
........
.....**.
...*....
........
        \n
        \n
        \n
        \n
        \n
        \n
        \n
        \n

Sample Output

Copy
65
  \n
Source: CSES, Introductory Problems, 1624

Submit

请先 登录

© 2025 FAQs