A local street planning consulting company, Rue's Rings, is looking to help the city prepare for converting a lot of their medium-traffic one-lane intersections into roundabouts.
After generating a plan, the city wants to run a simulation to see where the possible bottlenecks of traffic could be. The simulation runs by finding the roundabouts along a route and then figuring out which roundabout is the smallest in diameter. The smallest diameter roundabout would be the best possible location for congestion and creating a bottleneck of traffic which would make the traffic patterns even worse than they are now.
There are
Input Specification
The standard input will contain 10 datasets. Each dataset begins with an integer
The first integer of each route description is the ID for the route. The second integer
Output Specification
For each dataset, output the minimum roundabout diameter along a route followed by a brace-enclosed, sorted list of route IDs for the routes that could cause issues.
Sample Input (Two Datasets Shown)
3
1 6 4 5 2 6 3 2
2 3 2 3 4
3 4 2 3 2 4
4
1 2 3 4
2 3 4 2 4
3 7 2 3 3 4 5 2 6
4 5 3 2 5 1 4
Sample Output
2 {1,2,3}
1 {4}
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments
I couldn't solve the problem because of one space: my output is '2 {1, 2, 3}', and it must be '2 {1,2,3}'
I'm very lucky and i know it ;-)
Don't forget to convert your route numbers to int before finding the minimum!
reminder/hint (python): if considering using sets in output -> they are unordered...;)
Just a heads up for anyone having trouble with the 2nd and 3rd test cases, the ID numbers don't always appear in order. I wrongly assumed this because it wasn't specified in the question and the sample cases are very basic.
Thank you for commenting about the sorting. I would never have figured that out had you not said it. I did read over the problem again and in the output specification it does mention needing a "sorted list of route IDs"