Toggle navigation
万里ACM
F.A.Qs
Web Board
ProblemSet
Source/Category
Status
Ranklist
Contest
[
ProblemSet
Status
Ranklist
OI Ranklist
Statistics
]
Login
Problem F: N皇后问题(Queen.cpp)
Problem F: N皇后问题(Queen.cpp)
Time Limit:
1 Sec
Memory Limit:
128 MB
Submit:
165
Solved:
75
[
Submit
] [
Status
] [
Web Board
] [Creator:
]
Description
在N*N的棋盘上放置N个皇后(n<=11)而彼此不受攻击(即在棋盘的任一行,任一列和任一对角线上不能放置2个皇后),编程求解所有的摆放方法。
Input
输入:
n
Output
每行输出一种方案,每种方案顺序输出皇后所在的列号,每个数占5列。若无方案,则输出
no solute!
Sample Input
Copy
4
Sample Output
Copy
2 4 1 3 3 1 4 2