QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 512 MB 満点: 100

#11805. 三步隧道

統計

在一个遥远的城市中,有 $n$ 座建筑物沿一条从左到右的直线排列。由于城市呈直线型,交通状况一直很糟糕。

一家公司决定通过双向地下隧道连接这些建筑物,以提供一种替代的交通方式。每条隧道连接两座建筑物。为了使导航变得简单,公司决定,对于任意两座不同的建筑物 $a$ 和 $b$,必须能够仅通过隧道从 $a$ 到达 $b$,且满足以下条件:

  • 始终沿同一方向行进(换句话说,如果 $b$ 在 $a$ 的右侧,则始终从左向右行进;如果 $b$ 在 $a$ 的左侧,则始终从右向左行进);并且
  • 最多使用 3 条隧道。

你需要设计一组满足上述要求的隧道,且隧道总数不超过 $5 \cdot n$。注意,你不需要找到隧道数量最少的方案。

输入格式

输入仅包含一行,为一个整数 $n$,$2 \le n \le 500$。

输出格式

在输出的第一行,打印你计划建造的隧道数量 $m$。在接下来的 $m$ 行中,每行打印两个不同的整数,表示由相应隧道连接的建筑物编号。建筑物从左到右编号为 $1$ 到 $n$。

$m$ 必须小于或等于 $5 \cdot n$。你可以按任意顺序打印隧道。所有隧道必须是唯一的(例如,不允许同时包含 “1 2” 和 “2 1”)。

样例

样例输入 1

5

样例输出 1

5
1 2
2 3
3 4
4 5
1 5

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.