Canadian Computing Competition: 2024 Stage 1, Senior #4
Alanna, the mayor of Kitchener, has successfully improved the city's road plan. However, a travelling salesperson from the city of RedBlue complained that the roads are not colourful enough. Alanna's second job is to paint some of the roads.
Kitchener's road plan can be represented as a collection of intersections with roads, where the road connects intersections and . All roads are initially grey. Alanna would like to paint some of the roads in red or blue such that the following condition is satisfied:
To lower the city's annual spending, Alanna would like to minimize the number of painted roads. Can you help Alanna design a plan that meets all the requirements?
The first line contains two integers and ().
The of the next lines contains two integers and , meaning that there exists a road from intersection to intersection (, ).
There is at most one road between any unordered pair of intersections.
The following table shows how the available 15 marks are distributed:
| Marks | Additional Constraints |
|---|---|
| 2 | There is a road connecting intersection with intersection for all (and possibly other roads). |
| 3 | We can reach any intersection from any other intersection, and . |
| 3 | No road belongs to two or more simple cycles (see Definition below). |
| 7 | None |
Definition: if we denote a road between intersections and as , then a simple cycle is a sequence where and all are distinct.
Output a string of characters, representing the paint plan. The character should be R if the road is to be painted red, B if the road is to be painted blue, or G (for "grey") if the road is to be left unpainted.
Remember that you must minimize the number of painted roads while satisfying the condition. If there are multiple possible such plans, output any of them; your output does not have to match the sample output, and it is checked by verifying the condition on every grey road and counting the roads you painted.
A diagram of the intersections along with a valid paint plan that minimizes the number of painted roads is shown above. Note that the colours are shown on each road as R (red), B (blue), or G (grey).
All the unpainted roads satisfy the condition:
Note that it is possible for Kitchener to be disconnected.
No comments yet. Be the first to comment!