Skip to content

11539: 【原1539】Queen Challenge

题目

题目描述

author: 金耀楠 原OJ链接:https://acm.sjtu.edu.cn/OnlineJudge-old/problem/1539

Description

Consider the following 88 chessboard with 8 Queen on it. We must ensure that no one can capture any other Queen, that each row, each column and each angle online has only one queen. Here is an example of 66:

                    1   2   3   4   5   6                   
                1       ■                                   
                2               ■                           
                3                       ■                   
                4   ■                                       
                5           ■                               
                6                   ■

The layout above can be describe as 2 4 6 1 3 5 where the i-th number represent the position on the i-th row.

(This is the problem A for SEIEE-Yu Yong Data Structure 2015 Fall Exam 2)

Input Format

Only one number N, the board is N*N.

Output Format

4 rows, 1-3 row is the first three solutions by Lexicographical (Sorted by Alphabet). *note: If there are less than 3 answer, output only 2,1 or 0 line only.

The fourth row is a number, the number of solutions.

Sample Input

6

Sample Output

2 4 6 1 3 5
3 6 2 5 1 4
4 1 5 2 6 3
4

Data Range

100% : 4 <= N <= 13

Oops! 本题目还没有解答!

助教老师们编题的速度,已经超过了解题的速度!

OJ翻了一新,但本解答集还大多用的是2017-2019级,甚至更早的同学们贡献的答案。

如果你已经AC了,可以的话,请您参考添加页面,与大家一起分享你的题解!