P16123 [USTCPC 2026] Kruskal Loves Strongly Connected Graph

Background

**Please note that this problem has non-standard time and memory limits.** **Due to differences in judge machine performance, the time limit has been adjusted to 0.5 s.** Kruskal-chan likes strongly connected graphs, and she is dedicated to exploring their strong connectivity on various graphs.

Description

You are given a sequence $\{a_i\}$ of length $n$. Define $f_i=\max\limits_{1 \le j

Input Format

The first line contains a positive integer $n$ $(1 \le n \le 10^5)$, denoting the length of the sequence. The second line contains $n$ integers. The $i$-th positive integer $a_i$ $(1\le a_i\le 10^9)$ denotes the $i$-th element of the sequence.

Output Format

The first line outputs an integer $m$, denoting the minimum number of edges to add. In the next $m$ lines, each line outputs two positive integers $u,v$ separated by a space, denoting an added directed edge $u \rightarrow v$. You need to ensure that $0 \le m \le n$ and $u,v \in [1,n]$.

Explanation/Hint

Translated by ChatGPT 5