QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 512 MB 満点: 100

#18349. 国际象棋比赛

統計

Alex 在他的公司里组织了一场国际象棋比赛。这场比赛是 $n$ 个人的单循环赛,也就是说,每对选手之间都恰好要进行一场比赛。

然而问题在于,办公室里只有 $k$ 张棋盘($k \le \lfloor \frac{n}{2} \rfloor$)。因此,同时最多只能进行 $k$ 场比赛。我们把由 $2g$ 个不同的选手同时进行的 $g$ 场比赛称为一个“轮次”(round),其中 $1 \le g \le k$。

你的任务是帮助 Alex 制定一个轮次最少的比赛日程表。

输入格式

输入包含两个整数 $n$ 和 $k$($2 \le n \le 200$,$1 \le k \le \lfloor \frac{n}{2} \rfloor$)—— 选手人数和棋盘数量。

输出格式

第一行输出一个整数 $r$ —— 最少的轮次。

接下来输出 $r$ 个部分,描述每一轮的安排。在每个部分的第一行,输出一个整数 $g$($1 \le g \le k$)—— 该轮进行的比赛场数。接下来输出 $g$ 行,每行包含两个整数 —— 在该轮中对局的两位选手的编号。这 $2g$ 个整数必须是 $1$ 到 $n$ 之间互不相同的整数。

如果存在多种可能的解,输出其中任意一种即可。

样例

输入样例 1

4 2

输出样例 1

3
2
2 3
1 4
2
2 4
3 1
2
1 2
3 4

输入样例 2

5 2

输出样例 2

5
2
4 1
2 3
2
1 5
4 2
2
2 5
4 3
2
3 5
2 1
2
5 4
3 1

输入样例 3

6 2

输出样例 3

8
2
3 2
6 4
2
5 1
4 3
2
6 1
2 5
2
1 3
5 6
2
2 4
5 3
2
4 1
2 6
2
6 3
5 4
1
2 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.