Although Canada is a large country, many areas are uninhabited, and most of the population lives near the southern border. The Trans-Canada Highway, completed in 1962, connects the people living in this strip of land, from St. John's in the East to Victoria in the West, a distance of 7821 km.
Canadians like hockey. After a hockey game, thousands of fans get in their cars and drive home from the game, causing heavy congestion on the roads. A wealthy entrepreneur wants to buy a hockey team and build a new hockey arena. Your task is to help him select a location for the arena to minimize the traffic congestion after a hockey game.
The country is organized into cities connected by a network of roads. All roads are bidirectional, and there is exactly one route connecting any pair of cities. A route connecting the cities
You are to implement a procedure LocateCentre(N,P,S,D).
Example
As an example, consider the network of five cities in the top diagram on the right, where cities
Note
We remind contestants that with the given constraints, it is possible to submit a solution that passes Subtask 3 and fails Subtask 2. However, remember that your final score for the entire task is determined by only one of your submissions.
Subtask 1 [25 points]
Assume that all the cities lie in a straight line from East to West, and that the roads all follow this straight line with no branches. More specifically, assume that for all
There are at most
Subtask 2 [25 points]
Make the same assumptions as in Subtask 1, but there are at most
Subtask 3 [25 points]
The assumptions from Subtask 1 may no longer be true.
There are at most
Subtask 4 [25 points]
The assumptions from Subtask 1 may no longer be true.
There are at most
Implementation Details
- Implementation folder:
/home/ioi2010-contestant/traffic/
(prototype: traffic.zip) - To be implemented by contestant:
traffic.c
ortraffic.cpp
ortraffic.pas
- Contestant interface:
traffic.h
ortraffic.pas
- Grader interface: none
- Sample grader:
grader.c
orgrader.cpp
orgrader.pas
- Sample grader input:
grader.in.1
grader.in.2
Note: The first line of the input file contains . The following lines contain for between and . The following lines contain pairs for between and . - Expected output for sample grader input:
grader.expect.1
grader.expect.2
etc.
Comments