In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
There are towns with their own airports in the country X. We know the maximal capacities of the airports — the airport in the town can have at most connections with other towns. The task is to design the net of air connections among the towns in such a way that the town has exactly connections with other towns. We assume that connections are two-way and that each pair of towns has at most one connection between them.
Write a program that:
We assume that for the given data a solution exists. If there exists more than one solution the program should find only one. It can happen that there is no connection (even indirect) between a pair of cities.
In the first line of the standard input there is written one integer , , which is the number of towns. In the following lines there are written positive integers (one integer in each line).
Your program should write all the connections of the created net to the standard output. The description of each connection consists of two positive integers separated by a single space. These integers are the numbers of two connected towns. Each description should be placed in a separate line. The numbers of towns in a line can be written in an arbitrary order. Similarly, the order of connections is not important.
For the input data:
6 2 3 2 4 1 2
the correct result is:
4 2 4 1 4 3 4 6 2 5 2 1 3 6
Task author: Wojciech Guzicki.