問題一覧 > 通常問題

No.1831 Parasol

レベル : / AI推定難易度 : 1625 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 90
作問者 : riano / テスター : nok0 ygussany
お気に入りにしたユーザー ProblemId : 7390 / 自分の提出
問題文最終更新日: 2022-01-10 19:12:45
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 330 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。