Job Lookup

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

Julia's nn friends want to organize a startup in a new country they moved to. They assigned each other numbers from 1 to nn according to the jobs they have, from the most front-end tasks to the most back-end ones. They also estimated a matrix cc, where c_ij=c_jic\_{ij} = c\_{ji} is the average number of messages per month between people doing jobs ii and jj.

Now they want to make a hierarchy tree. It will be a binary tree with each node containing one member of the team. Some member will be selected as a leader of the team and will be contained in the root node. In order for the leader to be able to easily reach any subordinate, for each node vv of the tree, the following should apply: all members in its left subtree must have smaller numbers than vv, and all members in its right subtree must have larger numbers than vv.

After the hierarchy tree is settled, people doing jobs ii and jj will be communicating via the shortest path in the tree between their nodes. Let's denote the length of this path as d_ijd\_{ij}. Thus, the cost of their communication is c_ijd_ijc\_{ij} \cdot d\_{ij}.

Your task is to find a hierarchy tree that minimizes the total cost of communication over all pairs: _1i<jnc_ijd_ij\sum\_{1 \le i < j \le n} c\_{ij} \cdot d\_{ij}.

입력

The first line contains an integer nn (1n2001 \le n \le 200) -- the number of team members organizing a startup.

The next nn lines contain nn integers each, jj-th number in ii-th line is c_ijc\_{ij} --- the estimated number of messages per month between team members ii and jj (0c_ij109;c_ij=c_ji;c_ii=00 \le c\_{ij} \le 10^9; c\_{ij} = c\_{ji}; c\_{ii} = 0).

출력

Output a description of a hierarchy tree that minimizes the total cost of communication. To do so, for each team member from 1 to nn output the number of the member in its parent node, or 0 for the leader. If there are many optimal trees, output a description of any one of them.

힌트

The minimal possible total cost is 5661+2391+301+12+12=839566 \cdot 1+239 \cdot 1+30 \cdot 1+1 \cdot 2+1 \cdot 2=839: