Write a program to print the lexicographically smallest way to place queens on an chessboard so that no queen threatens another queen.
Input consists of a natural number .
Mark the queens with a ‘Q’, and the empty positions with
a dot. Print the lexicographically smallest way (by rows, from top to
bottom, and assuming that a ‘Q’ is smaller than a dot) to
place
queens on an
chessboard so that no queen threatens another queen. If there is no
solution, print “NO SOLUTION”.
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T10:36:24.478Z
© Jutge.org, 2006–2026.
https://jutge.org