QOJ.ac

QOJ

Límite de tiempo: 2.0 s Límite de memoria: 256 MB Puntuación total: 100

#12768. 友善班级里的孩子们

Estadísticas

Kevin 正在回忆他小学时的班级。班里有女生和男生。他们之间有些是朋友,有些不是。但如果一个人把另一个人当作朋友,那么反之亦然。

有趣的是,每个女生在女生中有恰好 $a$ 个朋友,在男生中有恰好 $b$ 个朋友;而每个男生在女生中有恰好 $c$ 个朋友,在男生中有恰好 $d$ 个朋友。

Kevin 不记得他班级的人数了。请帮助他重构这个班级,使得总人数尽可能少,且满足上述条件。

输入格式

输入仅一行,包含四个整数 $a, b, c$ 和 $d$ ($1 \le a, b, c, d \le 50$)。

输出格式

输出一个满足上述条件且总人数尽可能少的班级示例。

第一行应包含两个正整数:$m$(女生人数)和 $n$(男生人数)。

我们将女生编号为 $1$ 到 $m$,男生编号为 $m + 1$ 到 $m + n$。

接下来的每一行应包含一对不同的整数,描述一对朋友的编号。每一对朋友在列表中应恰好出现一次。

样例

输入 1

1 2 1 2

输出 1

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

说明

样例输出对应的班级结构如下图所示:

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.