CerealCodes II Novice |
---|
Finished |
Eric's $$$n$$$ red pandas have been mixed up!
They currently lie on the number line, occupying points $$$p_1, p_2, \dots p_n$$$. You are given the distance between all pairs of red pandas. Please help Eric figure out the order of the pandas.
The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 500)$$$, the number of test cases.
The first line of each test case contains an integer, $$$n$$$ $$$(1 \leq n \leq 1000)$$$.
Then the line after that contains $$$n$$$ integers, $$$p_1, p_2, \dots p_n$$$ $$$(1 \leq p_i \leq 10^9)$$$, given in increasing order.
Then $$$n$$$ lines follow. The $$$i$$$th of these lines will contain $$$n$$$ integers, $$$d_{i1}, d_{i2}, \dots d_{in}$$$, where $$$d_{ij}$$$ is the distance between red panda $$$i$$$ and red panda $$$j$$$. Note that a panda is distance $$$0$$$ from itself.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$1000$$$.
For each test case, output one line containing $$$n$$$ integers, $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the panda at point $$$p_i$$$. If there are multiple correct answers, output any.
231 2 30 1 21 0 12 1 041 3 8 90 6 2 56 0 8 12 8 0 75 1 7 0
3 2 1 3 1 4 2
For the first test case, both $$$[1, 2, 3]$$$ and $$$[3, 2, 1]$$$ are valid answers.
Problem Credits: Mythreya Dharani
Name |
---|