CF1214E Petya and Construction Set

题目描述

你需要构造出一个节点数为 $2n$ 的一棵树. 给出 $n$ 个范围在 $[1, n]$ 的正整数 $d_i$ . 你构造出来的树需要满足: 第 $2i - 1$ 个点与第 $2i$ 个点在树上的距离恰为$d_i$. 这里定义两个点 $u$ , $v$ 之间的距离为 $u$ 到 $v$ 路径上的边数. 如果有多种方案, 输出任意一种即可.

输入格式

The first line of the input contains a single integer $ n $ ( $ 1 \leq n \leq 100\,000 $ ) — the parameter of a construction set that defines the number of bulbs and the number of wires. Next line contains $ n $ integers $ d_1, d_2, \ldots, d_n $ ( $ 1 \leq d_i \leq n $ ), where $ d_i $ stands for the number of wires the chain between bulbs $ 2i $ and $ 2i - 1 $ should consist of.

输出格式

$2n-1$行, 每行两个正整数 $u_i$ 和 $v_i$ , 表示你构造的树上 $u_i$ 和 $v_i$ 之间连有一条边.

说明/提示

$1 \leq d_i \leq n \leq 10^5$