No.1831 Parasol
Problem Statement
You have cloth in $2N-1$ colors: for each integer $i$ with $1\leq i\leq 2N-1$, you have $i$ pieces of cloth of color $i$.
You have decided to use this cloth to make parasols for riano.
A parasol can be made by using $1$ piece each of cloth of $N$ different colors from the cloth you have.
However, riano thinks it would be boring if the same color schemes kept appearing,
so he wants to receive at most $2$ parasols of each color scheme (strictly speaking, parasols with the same set of colors used count as having the same color scheme).
What is the maximum number of parasols you can give to riano?
Also, output the color schemes of the parasols you make in that case.
Input
$N$
- $2\leq N \leq 300$
- All inputs are integers.
Output
On the $1$st line, output the maximum number of parasols that can be made while satisfying the conditions.
On each subsequent line (from line $2$ onward), output $N$ numbers representing the colors used for each parasol, separated by spaces. Any color schemes satisfying the conditions may be output, in any order.
However, do not include in the output any parasols that cannot be given to riano. That is, if the answer output on the $1$st line is $m$, the output must consist of $m+1$ lines in total.
Print a newline at the end.
Sample
Sample 1
Input
3
Output
5 1 4 5 2 3 5 2 4 5 3 4 5 4 3 5
You made $5$ parasols with the color schemes shown in the output. The $4$th and $5$th parasols have the same color scheme, but all the other parasols have different color schemes, so there are at most $2$ parasols of each color scheme, which satisfies riano's condition. Also, there are $1+2+3+4+5=15$ pieces of cloth in total and all of them have been used up, so this number of parasols is the maximum.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
riano
nok0