QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#9286. 构建非仙人掌图

统计

在图论中,仙人掌图(cactus)是指一个连通的无向图,其中任意两个简单环至多共用一个顶点。

给定一个整数 $n$,请构造一个具有 $n$ 个顶点的连通图,使得该图不是仙人掌图。注意,你的图中不能包含自环或重边。图中边的数量应尽可能少。

输入格式

输入包含一个整数 $n$ ($2 \le n \le 1000$)。

输出格式

如果不存在满足条件的 $n$ 个顶点的连通图(即不是仙人掌图且无自环、无重边),则在输出的第一行打印 -1。否则,首先打印一个正整数 $m$,表示图中边的数量。接下来打印 $m$ 行,每行包含两个整数,表示图中各条边。请使用 $1, 2, \dots, n$ 的连续整数对图中的顶点进行编号。

如果存在多个满足边数最少条件的解,打印其中任意一个即可。

样例

样例输入 1

3

样例输出 1

-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.