Codeforces 976C
题意略。
思路:由于题中只要让我们找出嵌套的段就行了,那么我们只需要排序一下就好了。
排序方式:按左端由小到大排,左端一样的时候,右端小的排在前。

如果你担心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的更多相关文章
- Codeforces 976C Nested Segments
题面: 传送门 C. Nested Segments Input file: standard input Output file: standard output Time limit: 2 secon ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
随机推荐
- Android CHM文件阅读器
CHM格式是1998年微软推出的基于HTML文件特性的帮助文件系统.以替代早先的winHelp帮助系统,它也是一种超文本标识语言.在Windows 98中把CHM类型文件称作“已编译的HTML帮助文件 ...
- springboot整合mybatis时无法读取xml文件解决方法(必读)
转 http://baijiahao.baidu.com/s?id=1588136004120071836&wfr=spider&for=pc 在springboot整合myba ...
- TCP三次握手抓包理解
TCP建立连接需要三次握手,分手需要四次握手,平时在网上看到很多次,但是还没有很理解.为什么分手要多一次?可能是刚开始追求女生的时候比较容易,到分手的时候就比较麻烦了吧... 了解某个东西要从它的基础 ...
- 详解iframe与frame的区别
iframe与frame的区别 一.使用iframe的优缺点 优点: 1.程序调入静态页面比较方便; 2.页面和程序分离; 缺点: 1.iframe有不好之处:样式/脚本需要额外链入,会增加请求.另外 ...
- bean的创建(五)第四部分 bean构造器的查找
前面分析了bean的静态工厂查找 bean的构造器查找过程和bean的静态工厂查找类似 protected BeanWrapper createBeanInstance(String beanName ...
- 0 ElasticSearch
注意事项 需要jdk环境1.7以上 Elasticsearch Kibana 的下载地址统一为https://www.elastic.co/downloads/ 问题排查可以登录https://dis ...
- 【iOS】沙盒目录
有关沙盒目录参考: http://blog.csdn.net/totogo2010/article/details/7669837 获取沙盒路径,参考代码: NSArray *paths = NSSe ...
- 【iOS】删除 main.storyboard 的问题
一直没用 main.storyboard, 后来索性把它删了,结果还出了问题: Terminating app due to uncaught exception 'NSInvalidArgument ...
- 安装使用xen虚拟化工具
换了一家新公司,需要拿出一套虚拟化方案,就把业界的主流虚拟化技术划拉了一遍,给领导交了一份报告,具体的技术部分已经在之前的随笔里了,本篇文章主要介绍的是xen虚拟化工具的安装: Xen官方部署文档:h ...
- 使用阿里云对docker拉取镜像加速
使用docker的时候,总是需要去search镜像,使用国外的源下载太慢,还有诸多的限制,无意中发现可以使用阿里云进行加速,实测有用,废话少说,操作如下: 1.打开阿里云控制台,没有的可以用淘宝账号或 ...