516 - 競程 CPE 班 (2013/10/03) Scoreboard

Time

2013/10/03 19:00:00 2013/10/03 22:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
9039 Output Format
9376 sparse high-dim points

9039 - Output Format   

Description

Output the given strings according to the defined format.

Input

The first line of input contains a positive integer t (t <= 20), which indicates the number test cases.  For each case, the first line contains one positive integer n (n <= 100) indicating the number of strings.  In the next n lines, one string is appeared per line.  The length of each string is between 1 and 20.

Output

The output format is as follows.  First, each line has 4 strings.  Second, each string occupies 20 spaces and right aligned.Print a blank line after each case.

Sample Input  Download

Sample Output  Download

Tags




Discuss




9376 - sparse high-dim points   

Description

Input will give you a lot of “multi dimension” points, and your mission is to find the minimum distance of all the possible pairs.
The point will give you as follows:
If a 5-dimension point like (1,0,0,3,2), I will give the (index,value) pair in a single line such as (1,1);(4,3);(5,2)


And you can assume that the dimension of each test case is same, because you can fill zero as you want. This means that (1,0,0,3,2) may become 7-dimension such as (1,0,0,3,2,0,0)


And the distance means the Manhattan distance.
P1(p11,p12,p13,p14)
P2(p21,p22,p23,p24)
The distance of P1 and P2 is abs(p11-p21)+abs(p12-p22)+abs(p13-p23)+abs(p14-p24)

abs means the absolute value.

Input

The input includes multiple test cases. In each test case, there are many lines, each line represent a point in the format: (index1,value1);(index2,value2);…(indexM,valueM)
After all the points, ther is a single line “END” represent the ending of this test case.
See the sample input clearly.


The number of points : N
The range of index : idx
The number of pair in a single line I will give you : D
The value of the point : val

case 1: 2<=N<=10, 1<= idx <=5, 1<=D<=5, 0<=val<=100
case 2: 2<=N<=50, 1<= idx <=50, 1<=D<=50, 0<=val<=10^4
case 3: 2<=N<=50, 1<= idx <=10^4, 1<=D<=300, 0<=val<=10^6
case 4: 2<=N<=100, 1<= idx <=10^6, 1<=D<=10^3, 0<=val<=10^8

For example, in case 3, there may be a test case that has 50 points, and each point in the format:
(index1,value1);(index2,value2);…(indexM,valueM)
Then 1<=index1,index2,…indexM<=10^4,
And 0<=value1,value2,…valueM<=10^6
And D = 300 means each point I will give you at most 300 pairs, that is 1<=M<=300.

Output

For each test case, output the minimum distance of all the possible pairs.

Sample Input  Download

Sample Output  Download

Tags




Discuss