# | Problem | Pass Rate (passed user / total user) |
---|---|---|
12496 | Eight Queen |
|
13333 | Stewie vs Brian |
|
13337 | Karpet Sierpinski |
|
Description
Each chessboard has numbers written on each square and is supplied with 8 chess queens. The task is to place the 8 queens on the chessboard in such a way that no queen threatens another one, and so that the sum of the numbers on the squares selected is the minimum. (For those unfamiliar with the rules of chess, this implies that each row and column of the board contains exactly one queen, and each diagonal contains no more than one queen.)
Write a program that will read in the number and details of the chessboards and determine the lowest scores possible for each board under these conditions.
Input
Input will consist of K (the number of boards), on a line by itself, followed by K sets of 64 numbers, each set consisting of eight lines of eight numbers. Each number will be a non-negative integer less than 10000. Each case is separated by a blank line. There will never be more than 20 boards.
Output
The outputs of all test cases should be printed in order. For each test case a line, print the lowest score.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Stewie and Brian are competing against each other in a game of partially filled sudoku.
The one who finishes it first wins.
Stewie can finish a 9x9 sudoku in 3 minutes.
Help Brian build a program so he can finish it before stewie.
Example of a solved sudoku:
Input
9x9 2d array with numbers ranging from 0 to 9
The 0 represents blank needed to be filled
Output
Solved 9x9 sudoku
If there's no solution, printt "no solution\n"
Sample Input Download
Sample Output Download
Tags
Discuss
Description
This can be solved with recursion.
The Sierpinski Carpet is a self-similar pattern with 8 non-overlapping copies of itself.
It starts with a white square divided into 9 smaller subsquares, which interior square is filled with black (Depth = 1).
To obtain a carpet at Depth = 2, do the same procedure recursively to the remaining 8 subsquares.
Here is an example of the carpet with Depth 1, 2, 3, & 4.
Input
Input contains single integer n, the Depth of the carpet (1 <= n <= 8).
Output
Please output the Sierpiński carpet of side length 3n and use '.' to represent white, '#' to represent black.