CF620C Pearls in a Row
Description
There are $ n $ pearls in a row. Let's enumerate them with integers from $ 1 $ to $ n $ from the left to the right. The pearl number $ i $ has the type $ a_{i} $ .
Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.
Split the row of the pearls to the maximal number of good segments. Note that each pearl should appear in exactly one segment of the partition.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use scanf/printf instead of cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
Input Format
The first line contains integer $ n $ ( $ 1
Output Format
On the first line print integer $ k $ — the maximal number of segments in a partition of the row.
Each of the next $ k $ lines should contain two integers $ l_{j},r_{j} $ ( $ 1