Note: This problem differs from cco24p4 only in the scoring.
Ondrej and Edward are spies and they are going to take down the evil organization AQT.
To do so, they will need to infiltrate into the AQT base. The base can be modelled as a tree with rooms, labelled from 0 to . Ondrej and Edward's plan to infiltrate the base is to first get kidnapped and then meet up together before executing their plan. When kidnapped, the two will be placed into different rooms unknown to each other. Once they are placed into the rooms, they will both break free at midnight and try to meet up with each other before executing their plan.
Their plan to meet up is as follows. At every odd minute, Ondrej can choose to stay at his current room or move to an adjacent room. At every even minute, Edward can choose to stay at his current room or move to an adjacent room.
A strategy is defined as the following. Let denote the room agent should be at assuming that they were at room at midnight and it is currently minutes after midnight. The strategy should match the conditions above. The agents are said to meet up at time , which is the first time where .
Ondrej and Edward want to meet up as fast as possible, relative to the distance between their two starting rooms. The distance is the minimum number of corridors that must be traversed to reach from . Please help find a strategy that minimizes the maximum across all pairs of different rooms and .
Input Specification
The first line of input will contain .
The next lines will each contain two space-separated integers, denoting the labels of two rooms with a bidirectional corridor between them.
Output Specification
First output a positive number , the number of entries per starting room. Note that must be satisfied, otherwise you will be awarded no points.
Then, output Ondrej's strategy, followed by Edward's strategy.
To output an agent's strategy, output lines, where the -th line (starting from 0) represents the agent's path if they start at room . For each line, output spaced integers: The room label that the agent should be in at time 1, 2, . . . , .
Scoring
If the output is invalid or there exists a test case and a pair of different rooms and where the agents do not meet at or before time , then no points will be awarded.
Otherwise, let be the maximum among all test cases and pairs of and of the value of . Let be the optimal known so far. Currently, (please comment below if you believe you've found a more optimal ).
Your score (out of ) will be if and given by the following expression otherwise.
Sample Input 1
5
0 2
3 2
1 4
2 4
Sample Output 1
8
2 2 4 4 1 1 1 1
1 1 1 1 1 1 1 1
3 3 2 2 3 3 2 2
3 3 2 2 0 0 2 2
4 4 4 4 2 2 2 2
0 2 2 3 3 3 3 2
1 4 4 2 2 0 0 0
2 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3
4 1 1 1 1 4 4 4
Explanation for Sample 1
Note that this is an invalid test case as , so it will not appear in the test cases when judging. The output for the test case is valid. Note that this would not score any points because if Ondrej starts at room 1 and Edward starts at room 3, then they will never meet each other.
Comments
https://dmoj.ca/submission/6493135 it turns out 10.63 is possible? (credits: errorgorn for idea). Edit: tested locally on a straight line I got the ratio 10.8154
I've updated the value of based on the new best solution https://dmoj.ca/submission/6501033. Also changed the scoring to be linear instead of quadratic, since the older solutions were getting way too few points now that is so large.