Forever and Always
Time limit2sMemory limit512 MB
Build preference lists for a repeated voting process so that at least p iterations run before no one changes their vote.
- Level
Medium6 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Statement
Consider an abstract voting procedure. For example, this might be a vote for the best song by Bullet for My Valentine in 2019.
There are persons taking part in the vote, and options to vote for. Each person has a preference list that includes some of the options, ordered from most preferred to least preferred. An option missing from a preference list is unacceptable to that person, not merely less preferred.
Voting proceeds in iterations.
In the first iteration, every person votes for the first option on their preference list. The number of votes for each option is counted and announced to everyone.
In every later iteration, each person votes for the option on their preference list that received the most votes in the previous iteration. If several such options exist, the one earlier on the preference list wins.
Before each iteration, the procedure asks whether anyone is going to vote differently from the previous iteration. If no one is, the iteration is not conducted, and the results of the last iteration are declared final. Otherwise, everyone votes as described, the votes are counted and announced again, and the votes of earlier iterations are ignored.
This procedure looks cumbersome, and it may seem that the results could take forever to find. To prove this, propose values of , and preference lists such that at least 100 iterations of voting are conducted.
Input
The only line of the input contains a single integer , the required number of iterations.
There are two test cases. In test case 1, . In test case 2, .
Output
Output two integers and (; ), the number of persons and the number of options. Then output the preference lists.
Each preference list is described by (), the number of options on the list, followed by distinct integers (), the option identifiers in order from most preferred to least preferred.
The sum of all must not exceed .
Hint
Consider the example test case.
In the first iteration, everyone votes for the first option on their list. So the first person votes for option 1, the second and fourth persons vote for option 2, and the third person votes for option 5.
In the second iteration, option 2 leads, so the first person changes their vote from option 1 to option 2. Everyone else keeps their vote. In particular, the third person keeps voting for option 5, since options 5 and 1 each had one vote in the first iteration, and option 5 comes earlier on their list.
The third iteration is not conducted because nobody wants to change their vote. Two iterations were conducted, which satisfies .