1878 - I2P(I)2019_Hu_lab5_8_makeup Scoreboard

Time

2019/12/23 20:40:00 2019/12/23 22:40:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12496 Eight Queen
12511 Pointer Sorting

12496 - Eight Queen   

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




12511 - Pointer Sorting   

Description

You will need to write a function to solve sorting problem.

int** s(int* ptr,int len);

ptr is a pointer, len is the length of ptr and is a complete square number, after we allocate it space according by the input.

After sorting ptr in non-descending order, you need to put it in a 2D array in row-major order, then return it in int** type.

 

Input

you don't need to worry it

Output

A 2D matrix

 

Remember to change line each row.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12511.c

Partial Judge Header

12511.h

Tags




Discuss