QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#16010. Key Properties

統計

Dwarf the Aesthete 是一位著名的艺术鉴赏家。在他的家中,收藏了大量的画作。他最喜欢的一幅画描绘了一个包含 10 个顶点的图,如下图所示:

第一个样例输出的示意图。

有一天,在欣赏他最喜欢的画作时,Dwarf the Aesthete 发现了这个图之所以如此出色的原因:它是连通的,每个顶点恰好有 3 条关联边,且图中不包含长度为 4 的环(即对于任意四个不同的顶点 $v_1, v_2, v_3, v_4$,不存在四条边 $(v_1, v_2)$、$(v_2, v_3)$、$(v_3, v_4)$ 和 $(v_4, v_1)$)。

意识到这一点后,Dwarf the Aesthete 想知道是否还存在其他具有这些性质的图。由于他想成为艺术界的大人物,他只对大型图感兴趣,即顶点数至少为 42 的图(对他来说,42 似乎是一个很酷的数字)。

请帮助他:对于给定的顶点数,构造一个具有上述性质的无向简单图(没有自环,且同一对顶点之间没有多条边),或者确定不存在这样的图。

输入格式

输入的第一行也是唯一一行包含一个整数 $N$,表示顶点数。

输出格式

如果不存在满足条件的图,输出 NO。

否则,在第一行输出一个整数 $M$,表示图中的边数。

接下来的 $M$ 行,每行包含两个整数 $a_i$ 和 $b_i$ ($1 \le a_i, b_i \le N$),表示一条边的两个端点。

如果存在多个合法的解,你可以输出其中任意一个。

数据范围

$42 \le N \le 10^6$。

样例

输入 1

10

输出 1

15
1 2
2 3
3 4
4 5
5 1
1 6
2 7
3 8
4 9
5 10
6 8
8 10
10 7
7 9
9 6

输入 2

8

输出 2

NO

说明

注意:上述样例不满足 $N \ge 42$ 的条件,因此你不需要通过这些样例。评测系统中的样例满足 $N = 42$。

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.