思路:按照l小到大排个序,相等r大到小排个序,挨着找就可以了。
代码:
#include
using namespace std;
const int maxn=3e5+5;
typedef long long LL;
struct node
{
int l;
int r;
int id;
}a[maxn];
bool cmp(node x,node y)
{
if(x.l==y.l) return x.r>y.r;
return x.l=a[i+1].r)
{
flag=true;
printf("%d %d\n",a[i+1].id,a[i].id);
break;
}
}
if(!flag) printf("-1 -1\n");
}
return 0;
}