#P7403. [BalticOI 2002] Tennis Club (Day1)

[BalticOI 2002] Tennis Club (Day1)

Description

There are NN people who want to make friends with each other. Person ii wants to make friends with GiG_i people.

Find one feasible assignment of friendships.

Input Format

The first line contains an integer NN, representing the number of people.
The next NN lines each contain an integer GiG_i, meaning that person ii wants to make friends with GiG_i people.

Output Format

If there is no solution, output NO SOLUTION in one line.
If there is a solution, first output SOLUTION in one line.
Then output NN lines, where line ii contains GiG_i integers, indicating with which people person ii makes friends.

Note that in any solution, the GiG_i integers in line ii must be output in increasing order.
If there are multiple solutions, output any one of them.

3
1
2
1 
SOLUTION
2
1 3
2 
3
2
2
1 
NO SOLUTION

Hint

Constraints

For 100%100\% of the testdata, 2N10002 \le N \le 1000, 1Gi<N1 \le G_i < N.

This problem uses Special Judge.

Notes

Translated from BalticOI 2002 Day1 B Tennis Club

Translated by ChatGPT 5