0 人解决,2 人已尝试。
0 份提交通过,共有 10 份提交。
9.9 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
The Matchball tennis club is organizing a “game interest week” to attract new players to the club. As one of the attractions, they have asked some star players to play a few demo games. Each star has indicated the number of games he or she is willing to play. The organizers want the stars to have some fun as well, thus they want to schedule the games so that no two players meet more than once with each other.
Your task is to write a program to help them match the players into pairs so that each player plays his or her desired number of games and does not play twice or more against any other player. Of course, no player may play against himself or herself.
On the first line of the input is the number of players N (2 <= N <= 1000) and on the following N lines is the desired number of games to play Gi (1 <= Gi < N) for each player. Assume that the players are numbered from 1 to N in the order of their wishes in the input.
On the first line of the output write NO SOLUTION if it is not possible to create a schedule so that the wishes of all players are satisfied, or SOLUTION if it is possible.
If a schedule exists, write it out on the following N lines. On each line write the indices of opponents for the player whose desired number of games was indicated on the corresponding input line. On each line the indices must be in increasing order and separated by spaces. If multiple solutions exist, output any one of them.
3 1 2 1
SOLUTION 2 1 3 2
0 人解决,2 人已尝试。
0 份提交通过,共有 10 份提交。
9.9 EMB 奖励。