CF976C Nested Segments
Description
You are given a sequence $ a_{1},a_{2},...,a_{n} $ of one-dimensional segments numbered $ 1 $ through $ n $ . Your task is to find two distinct indices $ i $ and $ j $ such that segment $ a_{i} $ lies within segment $ a_{j} $ .
Segment $ [l_{1},r_{1}] $ lies within segment $ [l_{2},r_{2}] $ iff $ l_{1}>=l_{2} $ and $ r_{1}
Input Format
The first line contains one integer $ n $ ( $ 1
Output Format
Print two distinct indices $ i $ and $ j $ such that segment $ a_{i} $ lies within segment $ a_{j} $ . If there are multiple answers, print any of them. If no answer exists, print -1 -1.
Explanation/Hint
In the first example the following pairs are considered correct:
- $ (2,1),(3,1),(4,1),(5,1) $ — not even touching borders;
- $ (3,2),(4,2),(3,5),(4,5) $ — touch one border;
- $ (5,2),(2,5) $ — match exactly.