QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#4199. 公交线路

الإحصائيات

在经历了多年没有公共交通的日子后,Krockholm 镇终于要建立一个公交线路网了。规划方案尚在绘图板上,但已经决定将会有 $n$ 个车站,编号为 $1$ 到 $n$,以及 $m$ 条公交线路,每条线路连接两个车站。目前唯一剩下的工作就是决定哪些车站对之间应该建立连接。一个重要的要求是,必须能够从任意一个车站到达其他任何车站。此外,有人提出了一个绝妙的主意:公交线路应该根据其端点编号之和来标记。这意味着所有这些和必须互不相同。

给定两个整数 $n$ 和 $m$。请构造一个具有 $m$ 条边和 $n$ 个顶点(编号为 $1$ 到 $n$)的图,使得:

  1. 该图是连通的。
  2. 所有边的端点编号之和互不相同。

输入格式

输入包含一行,包含两个整数 $n$ 和 $m$ ($2 \le n \le 100, 1 \le m \le 10^4$)。

输出格式

如果无法构造出满足给定属性的图,请输出 “-1”。否则,输出 $m$ 行,其中第 $i$ 行包含两个整数 $a_i, b_i$,表示第 $i$ 条边的两个端点。如果存在多种可能的解,输出其中任意一个即可。

样例

样例输入 1

4 4

样例输出 1

2 1
2 3
4 3
4 2

样例输入 2

10 100

样例输出 2

-1

样例输入 3

10 1

样例输出 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.