QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 512 MB مجموع النقاط: 100 الصعوبة: [عرض]

#1807. 棒の分配

الإحصائيات

$N$ 本の金属棒がある。$i$ 番目の金属棒の重さは $2i - 1$ である。

あなたのタスクは、これらの金属棒を2つ以上のグループに分け、各グループの金属棒の重さの合計が等しくなるようにすることである。もしそれが不可能であれば、その旨を判定せよ。各金属棒は必ずいずれか1つのグループに属さなければならず、金属棒を切断することは許可されていないことに注意せよ。

入力

入力は1つの整数 $N$ ($2 \le N \le 10^5$) からなる。

出力

金属棒を2つ以上の等しい重さのグループに分ける方法がない場合は、$-1$ を1行に出力せよ。

それ以外の場合は、1行目にグループの数 $G$ ($2 \le G \le N$) を出力せよ。続いて、$G$ 行を出力せよ。各行は対応するグループを表す。$i$ 番目の行は、そのグループに含まれる金属棒の数 $K_i$ で始まり、続いてそのグループに含まれる金属棒の重さを $K_i$ 個出力せよ。すべての金属棒は必ずいずれか1つのグループに割り当てられなければならず、すべてのグループにおける金属棒の重さの合計は等しくなければならない。

解が複数存在する場合は、そのうちのどれを出力してもよい。

入出力例

入力 1

4

出力 1

2
2 1 7
2 3 5

入力 2

2

出力 2

-1

入力 3

3

出力 3

-1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.