当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6872:Skyscrapers

题目描述
You are asking to write a solver for the skycrapers puzzle. The following is the rule for this puzzle:

Place a number from 1 to $n$ (integers only) into each cell so that each number appears exactly once in each row and column. ($n$ is the number of cells in each row.) Each number represents a skyscraper of its respective height. The numbers outside the grid indicate how many skyscrapers can be seen in the respective row or column from the respective direction; smaller skyscrapers are hidden behind higher ones. In other words, a skyscraper is visible if numbers of all skyscrapers in front of it are slower.



输入解释
The first line contains an integer $T (1\leq T\leq 100)$ - the number of test cases.

For each test cases, the first line contain an interger $n (4\leq n\leq 8)$. There are $n$ integers in each of the following $4$ lines, indicating the clues on the top, bottom, left and right side (from left to right or top to bottom).

It' guarantees that every puzzle has a unique solution.

All puzzles in the inputs are from [puzsq](https://puzsq.jp/main/index.php?puzzle=59) and [puzzlinkdb](https://puzz.link/db/?type=skyscrapers)
. So if you get TLE, you can try to solve these puzzles locally by your program, or even by hand. However, there is no precomputed thing in the model solution.
输出解释
For each test, output $n$ lines with $n$ numbers in each line.
输入样例
2
5
0 0 0 5 0
0 4 2 0 0
0 0 4 3 0
3 3 0 0 0
6
0 4 0 0 3 0
0 0 4 0 0 0
0 3 0 4 0 5
0 4 0 3 0 0
输出样例
4 5 3 1 2
5 4 1 2 3
1 2 4 3 5
2 3 5 4 1
3 1 2 5 4
6 1 4 2 3 5
1 2 6 5 4 3
4 5 3 1 6 2
3 4 5 6 2 1
5 6 2 3 1 4
2 3 1 4 5 6
来自杭电HDUOJ的附加信息
Recommend IceyWang

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6872

最后修改于 2020-10-25T23:35:06+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 65536/65536K(Java/Others)