Pavel is developing another game. To do that, he again needs functions available in a third-party library too famous to be called. There are mm functions numbered from 11to mm, and it is known that the ii-th version of the library contains functions from aiai to bibi inclusively.

The library is not free and Pavel needs all the functions. What minimal number of versions does he need to purchase to be able to use all the functions?

Input

The first line contains two integers nn and mm (1≤n≤200000,1≤m≤1091≤n≤200000,1≤m≤109) — the number of library versions and the number of functions.

Each of the next nn lines contains two integers aiai and bibi (1≤ai≤bi≤m1≤ai≤bi≤m) — the interval of function numbers available in the ii-th version.

Output

In the first line output «YES» or «NO», depending on if it's possible or not to purchase library versions to use all the functions.

In case of the positive answer output two more lines. In the second line output a single integer kk — the minimal number of library versions needed to be purchased. In the third line output kk distinct integers — the numbers of versions needed to be purchased.

If there are several possible answers, output any of them.

Examples

Input
4 8
1 2
3 4
5 6
7 8
Output
YES
4
1 2 3 4
Input
4 8
1 5
2 7
3 4
6 8
Output
YES
2
1 4
Input
3 8
1 3
4 5
6 7
Output
NO
题解:首先按照左端点从小到大排序,左端点相同按照右端点从大到小排序。然后贪心选取,将设当前能到达的最远点为now,我们需要在左端点<=now+1的线段中选取右端点最大的放进去,之后更新now。
其他不满足的情况特判即可。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=;
struct node
{
int l,r,id;
}q[maxn];
int cmp(node a,node b)//按左端点从小到大,右端点从大到小排序
{
if(a.l==b.l)return a.r>b.r;
return a.l<b.l;
}
vector<int>ans;
int main()
{
int n,m;
cin>>n>>m;
for(int i=;i<=n;i++){
cin>>q[i].l>>q[i].r;
q[i].id=i;
}
sort(q+,q++n,cmp);
if(q[].l!=)return cout<<"NO"<<endl,;
int now=q[].r;
ans.push_back(q[].id);//首先将第一条放进去
for(int i=;i<=n;){
if(q[i].l>now+)return cout<<"NO"<<endl,;
else{
int temp=now,pos=q[i].id;
while(i<=n&&q[i].l<=now+){//在当前now可连接的取右端点最大值
if(q[i].r>temp){
temp=q[i].r;
pos=q[i].id;
}
i++;
}
if(now==temp)continue;//防止不必要的放入
now=temp;
ans.push_back(pos);
}
}
if(now<m)return cout<<"NO"<<endl,;
cout<<"YES"<<endl;
cout<<ans.size()<<endl;
for(int i=;i<ans.size();i++){
cout<<ans[i]<<" ";
}
cout<<endl;
return ;
}

最新文章

  1. 关于android LinearLayout的比例布局(转载)
  2. php 数组操作
  3. 05_IOC容器装配Bean(注解方式)
  4. GNU make 总结 (四)
  5. jQuery学习教程(3)
  6. codeforces 610B
  7. resultMap之collection聚集
  8. 使用sp_configure启用 &#39;Ad Hoc Distributed Queries&#39;
  9. Android锁定屏幕或关闭状态-screen,高速按两次音量向下键来实现拍摄功能(1.1Framework在实现的形式层广播)
  10. dubbo 的monitor监视器安装问题——————monitor一直处于正在启动状态
  11. iOS开发之字数不一的多标签Demo
  12. Java spring实现文件下载
  13. SolrCloud的搭建与稳定性测试
  14. (后端)sql手工注入语句&amp;SQL手工注入大全(转)
  15. Windows命令查看文件MD5,SHA1,SHA256 文件校验
  16. spring boot项目使用外部tomcat启动失败总结
  17. ​《数据库系统概念》4-DDL、集合运算、嵌套子查询
  18. codeforces586B
  19. mysql limit 优化
  20. [Javascript] Understand Curry

热门文章

  1. Binary Tree和Binary Search Tree
  2. impala invalidate metadata和impala-shell -r作用相同
  3. springCloud 之 Eureka服务治理机制及代码运行
  4. springboot官网-&gt;application.properties文件
  5. Java笔记--反射机制
  6. PhoneGap简易配置使用
  7. 051、Java中使用while循环实现1~100的累加
  8. jmeter常见错误及解决方法
  9. IOCTL_DISK_GET_DRIVE_GEOMETRY
  10. Git详细命令