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 1−pi,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(0≤qi,j=qj,i≤106,qi,i=0), pi,j=qi,j106
Output
Output N−1 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,2⋅105].
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,j≤qi,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 e≈2.718281828459.
N/A