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个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
随机推荐
- NetCore跨平台桌面框架Avalonia的OSX程序打包
虽然工作开发语言已经转到了java,但平时仍会用netcore做一些小工具,提升工作效率,但是笔记本换成了Mac,小工具只能做成命令行形式,很是痛苦,迫切需要一个.net跨平台的桌面程序解决方案. 为 ...
- Python基础之变量,常量,注释,数据类型
由于上学期学了C语言,对于这一块的内容肯定算熟悉,只是注释的方法有些不同,但得还是一步一步的来!没有基础的同学看了这篇随笔也会大有助益的! 什么是变量?所谓变量就是将一些运算的中间结果暂存到内存中,以 ...
- 【数据库】postgresql数据库创建自增序列id的注意事项
1.创建一张表 CREATE TABLE "public"."tt" ( "name" varchar(128), "status ...
- 【Android Studio】类名字右下角红色的 J 【待解决】
问题如下图所示: 正在寻找结解决方法--
- linux字符设备驱动中内核如何调用驱动入口函数 一点记录
/* 内核如何调用驱动入口函数 ? *//* 答: 使用module_init()函数,module_init()函数定义一个结构体,这个结构体里面有一个函数指针,指向first_drv_init() ...
- zmnXAglTcg
#include <map>#include <cmath>#include <stack>#include <queue>#include <l ...
- python3学习-pickle模块
pickle提供了一个简单的持久化功能.可以将对象以文件的形式存放在磁盘上. 基本接口: pickle.dump(obj, file, [,protocol]) 注解:将对象obj保存到文件file中 ...
- template.demo.js
<!DOCTYPE html><html><head> <title>index</title> <meta charset=&quo ...
- 算法与数据结构基础 - 位运算(Bit Manipulation)
位运算基础 说到与(&).或(|).非(~).异或(^).位移等位运算,就得说到位运算的各种奇淫巧技,下面分运算符说明. 1. 与(&) 计算式 a&b,a.b各位中同为 1 ...
- Romantic HDU - 2669(扩欧)
#include<bits/stdc++.h> using namespace std; typedef long long LL; void gcd(LL a, LL b, LL &am ...