CF976C.Nested Segments

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a sequence a1,a2,...,ana_{1},a_{2},...,a_{n} of one-dimensional segments numbered 11 through nn . Your task is to find two distinct indices ii and jj such that segment aia_{i} lies within segment aja_{j} .

Segment [l1,r1][l_{1},r_{1}] lies within segment [l2,r2][l_{2},r_{2}] iff l1>=l2l_{1}>=l_{2} and r1<=r2r_{1}<=r_{2} .

Print indices ii and jj . If there are multiple answers, print any of them. If no answer exists, print -1 -1.
给你一个由编号为 1 到 n 的一维线段组成的序列 a1, a2, ..., an 。您的任务是找到两个不同的索引 i 和 j ,使得线段 ai 位于线段 aj 中。

如果有 l1 ≥ l2 和 r1 ≤ r2 ,那么线段 [l1, r1] 位于线段 [l2, r2] 中。

打印索引 i 和 j 。如果有多个答案,则打印任意一个。如果没有答案,则打印 -1 -1.

输入格式

The first line contains one integer nn ( 1<=n<=31051<=n<=3·10^{5} ) — the number of segments.

Each of the next nn lines contains two integers lil_{i} and rir_{i} ( 1<=li<=ri<=1091<=l_{i}<=r_{i}<=10^{9} ) — the ii -th segment.
输入
第一行包含一个整数 n(1n3105)n ( 1 ≤ n ≤ 3·10^5 ) - 片段数。
接下来的每 n 行包含两个整数 li 和 ri (1liri109)( 1 ≤ li ≤ ri ≤ 10^9 ) - 第 i 个线段

输出格式

Print two distinct indices ii and jj such that segment aia_{i} lies within segment aja_{j} . If there are multiple answers, print any of them. If no answer exists, print -1 -1.
输出
打印两个不同的索引 i 和 j ,使得线段 ai 位于线段 aj 中。如果有多个答案,则打印任意一个。如果没有答案,则打印 -1 -1 。

输入输出样例

  • 输入#1

    5
    1 10
    2 9
    3 9
    2 3
    2 9
    

    输出#1

    2 1
    
  • 输入#2

    3
    1 5
    2 6
    6 20
    

    输出#2

    -1 -1
    

说明/提示

In the first example the following pairs are considered correct:

  • (2,1),(3,1),(4,1),(5,1)(2,1),(3,1),(4,1),(5,1) — not even touching borders;
  • (3,2),(4,2),(3,5),(4,5)(3,2),(4,2),(3,5),(4,5) — touch one border;
  • (5,2),(2,5)(5,2),(2,5) — match exactly.
    注意
    在第一个示例中,下列配对被认为是正确的:
    (2, 1), (3, 1), (4, 1), (5, 1) - 甚至没有接触到边框;
    (3, 2), (4, 2), (3, 5), (4, 5) - 接触到一个边框;
    (5, 2), (2, 5) - 完全匹配。
首页