CF322A.Ciel and Dancing

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule:

  • either the boy in the dancing pair must dance for the first time (so, he didn't dance with anyone before);
  • or the girl in the dancing pair must dance for the first time.

Help Fox Ciel to make a schedule that they can dance as many songs as possible.

小狐狸Ciel和她的朋友们在一个舞蹈室里。这里有 nn 个男孩和 mm 个女孩,且他们此前从未跳过舞。接下来将播放若干首歌曲;每首歌播放时,必须恰好有一名男孩和一名女孩在跳舞。此外,还有一条特殊规则:

  • 跳舞的男孩必须是第一次跳舞(即他此前从未与任何人跳过舞);
  • 或者跳舞的女孩必须是第一次跳舞。

请帮助小狐狸Ciel制定一个安排方案,使得他们能够跳尽可能多的歌曲。

输入格式

The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.

第一行包含两个整数 nn 和 mm(1≤n,m≤1001 \leq n, m \leq 100)—— 分别表示舞厅中男孩和女孩的人数。

输出格式

In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.

第一行输出 k —— 他们可以跳舞的歌曲数量。随后的 k 行中,按时间顺序输出每首歌期间跳舞的男孩和女孩的编号。你可以假设男孩的编号为 1 到 n,女孩的编号为 1 到 m。

输入输出样例

  • 输入#1

    2 1

    输出#1

    2
    1 1
    2 1
  • 输入#2

    2 2

    输出#2

    3
    1 1
    1 2
    2 2

说明/提示

In test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).

And in test case 2, we have 2 boys with 2 girls, the answer is 3.

在测试用例 1 中,有 2 名男生和 1 名女生。我们可以安排 2 支舞:第 1 名男生与第 1 名女生(在第一首歌曲期间),第 2 名男生与第 1 名女生(在第二首歌曲期间)。

而在测试用例 2 中,我们有 2 名男生和 2 名女生,答案为 3。

输入解题思路,AI测评打分。不知道怎么写?

首页