QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 1024 MB Total points: 100

#3979. 游戏调度

Statistics

在一个拥有 $m$ 个队伍的锦标赛中,每个队伍由 $n$ 名选手组成。请构建一个比赛日程,使得每名选手都要与除本队以外的所有队伍中的所有选手进行比赛。也就是说,每名选手应进行 $(m - 1) \cdot n$ 场比赛。

比赛日程应划分为若干轮。每名选手在每一轮中最多只能进行一场比赛。如果一名选手在某一轮中没有比赛,则称该选手在该轮轮空。

你的任务是编写一个程序,构建一个比赛日程,使得没有任何选手轮空超过 1 轮。换句话说,比赛日程中的总轮数应不超过 $(m - 1) \cdot n + 1$。

比赛轮次的顺序、比赛的场次顺序,以及比赛中谁是主队谁是客队均不重要。

图片由 Pat Paker 通过 Wikimedia Commons 提供,CC BY

输入格式

输入包含一行,包含两个整数 $n$ 和 $m$ ($1 \le n \le 25, 2 \le m \le 25, n \cdot m \le 100$),分别表示每队的选手人数和总队伍数。

输出格式

输出比赛日程,每轮占一行。每一行应包含一个以空格分隔的比赛列表。比赛格式为 “-”。第一队的选手记为 A1, A2, ..., An;第二队记为 B1, B2, ..., Bn,以此类推。

样例

样例输入 1

3 2

样例输出 1

A1-B2 B1-A2 A3-B3
A2-B3 B2-A3 A1-B1
A3-B1 B3-A1 A2-B2

样例输入 2

2 3

样例输出 2

A1-B1 A2-C2 B2-C1
A1-C1 A2-B1 B2-C2
A1-B2 A2-C1 B1-C2
A1-C2 A2-B2 B1-C1

样例输入 3

1 5

样例输出 3

B1-E1 C1-D1
C1-A1 D1-E1
D1-B1 E1-A1
E1-C1 A1-B1
A1-D1 B1-C1

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.