Maximize the distance

3.8

10 votes
Mathematics, Hard, Probablity, Basic Probability, Probability
Problem

This is an approximate problem.

Consider a complete undirected graph with N vertices. You select a spanning tree from the graph, after that every edge (i,j) in the tree will be deleted with probability pi,j and with probability 1pi,j remains. In the remaining  forest for every i you compute D(i), the biggest distance from i to other accessible vertex j. You want to maximize the expected value of S=Nk=1D(k).

Input

The first line contains two integers - N,T(N=42) where T is the type of the test.

The (i+1)th line contains N nonegative integers - qi,1,qi,2,,qi,N(0qi,j=qj,i106,qi,i=0), pi,j=qi,j106

Output

Output N1 lines, each line will contain two numbers - u,v, meaning that there is edge (u,v) in the chosed tree.

Tests

The will be 60 tests generated by the following algorithms:

T=1, qi,j is generated uniformly in interval [0,106].

T=2, qi,j is generated uniformly in interval [0,2105].

T=3, qi,j is generated uniformly in interval [0,106]. After this it is applied Roy-Floyd shortest path algorithm on matrix q, thus obtaining qi,jqi,k+qk,j.

After the contest the current tests will be replaced by others generated with a different seed.

Score

The score will be eSα(T) where α(1)=80α(2)=α(3)=100 and e2.718281828459.

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

N/A

Editor Image

?