#P7978. 「Stoi2033」听见下雨的声音
「Stoi2033」听见下雨的声音
Description
SNS is going to hold a contest. There are a total of events, and the contest is held in rounds, with each event being used in exactly one round.
The principal wants the results to be more diverse, so he decides to find contestants with suitable strength from the students, such that in every event, everyone’s strength is pairwise different.
After selecting all contestants, the principal then makes a suitable schedule of rounds. In each round, for the corresponding event, the stronger half of the contestants advance, and the rest are eliminated and do not participate in later rounds, until only one contestant remains as the final champion.
The principal hopes that, among all different schedules of the rounds, the number of different people who could possibly become the champion is as large as possible. Now he wants to compute this maximum value, and for each contestant who can possibly become the champion, find one ordering of the events (i.e. a schedule of rounds) that makes them the champion.
Because the principal is busy, he asks you, the first AKIOIer in the school, to help him finish this task. Specifically, you need to first provide, for , the ranking of contestants’ strength from strongest to weakest in event (represented by a permutation of contestant IDs). Then, for each contestant who can possibly become the champion, you need to provide a permutation of representing an ordering of rounds that makes them the champion. See the Output Format.
Input Format
One line containing a positive integer .
Output Format
Output one number on the first line, meaning the maximum number of people who can possibly become the champion.
In the next lines, on line , output numbers in order, representing the contestant IDs ranked from strongest to weakest in event .
In the next lines, each line first outputs a number representing the ID of a contestant who can become the champion, then outputs a permutation of representing one scheduling method that makes become the champion.
Please make sure the output format is correct, otherwise the Special Judge may produce errors.
2
2
1 3 2 4
3 1 4 2
1 2 1
3 1 2
Hint
Sample Explanation
First, since there are at most different scheduling methods, it is clear that at most people can possibly become the champion.
For contestant , event first eliminates , leaving contestants . Then event eliminates , and finally becomes the champion.
For contestant , event first eliminates , leaving contestants . Then event eliminates , and finally becomes the champion.
Constraints
This problem has test points. For test point , it satisfies .
The scores of each test point are , respectively.
This problem provides the Special Judge source code and checker.exe (see Attachment Download). The following are possible return results of checker.exe and their meanings:
-
Wrong answer.: The number of possible champions is incorrect. -
Invalid contestant number.: An invalid contestant ID appears, including contestant IDs not being integers in , or a ranking not being a permutation of . -
Invalid item number.: An invalid event number appears, including event numbers not being integers in , or a ranking not being a permutation of . -
Contestant didn't won the first prize.: Some contestant cannot become the champion under the schedule you provided. -
Accepted: The answer is correct.
Translated by ChatGPT 5
京公网安备 11011102002149号