题意略。

思路:由于题中只要让我们找出嵌套的段就行了,那么我们只需要排序一下就好了。

排序方式:按左端由小到大排,左端一样的时候,右端小的排在前。

如果你担心1会因为2的阻隔而不能嵌套3的话,那么2可以保证嵌套3。

#include<bits/stdc++.h>
#define maxn 300005
using namespace std; struct edge{
int l,r,id;
edge(int a = ,int b = ,int c = ){
l = a,r = b,id = c;
}
bool operator<(const edge& e) const{
if(l != e.l) return l < e.l;
return r > e.r;
}
}; edge store[maxn];
int n; int main(){
scanf("%d",&n);
for(int i = ;i <= n;++i){
scanf("%d%d",&store[i].l,&store[i].r);
store[i].id = i;
}
sort(store + ,store + + n);
int ans1 = -,ans2 = -;
for(int i = ;i < n;++i){
if(store[i].l <= store[i + ].l && store[i].r >= store[i + ].r){
ans1 = store[i + ].id,ans2 = store[i].id;
break;
}
}
printf("%d %d\n",ans1,ans2);
return ;
}

Codeforces 976C的更多相关文章

  1. Codeforces 976C Nested Segments

    题面: 传送门 C. Nested Segments Input file: standard input Output file: standard output Time limit: 2 secon ...

  2. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  5. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  6. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  7. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  8. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  9. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

随机推荐

  1. 数据库---T-SQL语句:查询语句(二)

    >查询: 一.查询所有数据: select * from Info    ---查询所有数据(行) select Name from Info  ---查询特定列(Name列) select N ...

  2. z-index不起作用

    摘录自 https://blog.csdn.net/apple_01150525/article/details/76546367 z-index无效的情况,一共有三种:1.父标签 position属 ...

  3. 一、PyTorch 入门实战—Tensor(转)

    目录 一.Tensor的创建和使用 二.Tensor放到GPU上执行 三.Tensor总结 一.Tensor的创建和使用 1.概念和TensorFlow的是基本一致的,只是代码编写格式的不同.我们声明 ...

  4. BeanFactory体系结构

    BeanFactory是Spring中非常重要的一个类,搞懂了它,你就知道了bean的初始化和摧毁过程,对于深入理解IOC有很大的帮助. BeanFactory体系结构 首先看一下使用IDEA生成的继 ...

  5. 邮件服务配置(虚拟域&虚拟用户)

    邮件服务配置(虚拟域&虚拟用户) 现在我做的是: Linux + httpd + php + mariadb + postfix + dovecot + phpMyAdmin + postfi ...

  6. Spark 系列(四)—— RDD常用算子详解

    一.Transformation spark 常用的 Transformation 算子如下表: Transformation 算子 Meaning(含义) map(func) 对原 RDD 中每个元 ...

  7. tp5css和js引入问题

    由于以前用的是tp3.2,现在转用tp5开啊个人博客,在引入CSS和JS的时候遇到了一些坑 在3.2时期需要在路径中添加public,而在tp5中则直接引入static即可. 在config.php下 ...

  8. Notepad++编辑器——Verilog、代码片段、F6编译

    Notepad++是一款精致小巧的编辑器,自带Verilog语法识别功能,插件也挺好用的.这里陈列一下我的设置. 版本:Notepad++ 7.6.6 ,32位 //================= ...

  9. Python依赖包整体迁移方法

    1.新建site-packages目录,进入到site-packages目录下: 2.在site-packages目录下执行pip freeze >requirements.txt: 3.查看r ...

  10. Statement和PreparedStatement

    Statement与PreparedStatement的关系和区别: 关系:PreparedStatement继承自Statement,都是接口. 区别:PreparedStatement可以使用占位 ...