#P14051. [SDCPC 2019] Triangle City
[SDCPC 2019] Triangle City
题目描述
Triangle City is a city with intersections arranged into rows and columns, where the -th row contains intersections.
The intersections are connected by bidirectional roads. Formally, if we denote as the intersection on the -th row and the -th column, for all ,
- there is a road whose length is connecting intersection and , and
- there is a road whose length is connecting intersection and , and
- there is a road whose length is connecting intersection and .
What's more, for all , there exists a triangle whose sides are of length , and . That's why the city is called the Triangle City!
Our famous traveler BaoBao has just arrived in the Triangle City, planning to start his journey from intersection and end his trip at intersection . To fully enjoy the landscape, BaoBao would like to find the longest path from to such that each road is passed no more than once. Please help BaoBao find such a path.
Recall that if the sides of a triangle are of length , and , we can infer that , and .
输入格式
There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:
The first line contains an integer (), indicating the size of the city.
For the following lines, the -th line contains integers (), where indicates the length of the road connecting intersection and .
For the following lines, the -th line contains integers (), where indicates the length of the road connecting intersection and .
For the following lines, the -th line contains integers (), where indicates the length of the road connecting intersection and .
It's guaranteed that the sum of of all test cases will not exceed .
输出格式
For each test case output three lines.
The first line contains one integer , indicating the length of the longest path from to such that each road is passed no more than once.
The second line contains one integer , indicating the number of intersections on the longest path.
The third line contains integers separated by a space, where indicates the -th intersection on the longest path. Note that according to the description, there must be and .
If there are multiple valid answers, you can output any of them.
Please, DO NOT output extra spaces at the end of each line, or your solution may be considered incorrect!
3
2
3
2
4
2
1
1
1
3
100
100 100
1
100 1
100
100 100
7
3
1 1 2 1 2 2
2
3
1 1 2 1 2 2
700
8
1 1 2 1 3 2 2 2 2 1 3 1 3 2 3 3
提示
The sample test cases are shown below:
:::align{center}
:::