EIQUEENS - Eight queens puzzle
Xem dạng PDF
Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
The eight queens puzzle is the problem of placing eight chess queens on an ~8×8~ chessboard so that no two queens threaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal.
Input
- Input will contain a description of a single chess board, given as eight lines of eight characters each. Input lines will consist of only the characters
.and*. The.character represents an empty space on the board, and the ~*~ character represents a queen.
Output
- Print a single line of output. Print the word
validif the given chess board is a valid solution to the eight queens problem. Otherwise, printinvalid.
Example Input 1
*.......
..*.....
....*...
......*.
.*......
.......*
.....*..
...*....
Example Output 1
invalid
Example Input 2
*.......
......*.
....*...
.......*
.*......
...*....
.....*..
..*.....
Example Output 2
valid
Bình luận