QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 64 MB 満点: 100

#12292. 道路网络 2

統計

Byteasar 准备在 Byteland 进行一次公路旅行。不幸的是,他没能买到该国的地图。他从朋友那里了解到 Bytean 公路网的一些特性:

  • Byteland 有 $n$ 个城市,编号为 $1$ 到 $n$。
  • 每条道路都是双向的,连接两个不同的城市。
  • 任意两个不同的城市之间恰好有一条路径(由一条或多条道路组成),且路径中没有城市重复出现。
  • 从编号为 $i$ 的城市出发的道路恰好有 $d_{i}$ 条。

Byteasar 想要重建 Byteland 的公路地图。满足条件的公路网方案数量可能非常大,因此 Byteasar 对任何一个正确的方案都感到满意。

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 2\,000\,000$)。第二行包含 $n$ 个整数 $d_{i}$ ($1 \le d_i \le n-1$)。

输出格式

如果不存在满足输入条件的公路网方案,则输出的第一行也是唯一一行应包含单词 BRAK(波兰语,意为“无”)。否则,输出的每一行应包含一条双向道路的描述——两个在 $[1, n]$ 范围内的不同整数,表示该道路连接的城市编号。每条道路仅输出一次。输出中道路的顺序以及每条道路连接的城市顺序可以是任意的。

样例

输入 1

6
1 1 3 3 1 1

输出 1

1 3
2 3
3 4
5 4
6 4

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.