📄 2386728_ac_109ms_416k.cc
字号:
#include <algorithm>
using namespace std;
struct node
{
int x, y;
}pot[50001];
int n;
bool cmp(struct node a, struct node b)
{
if(a.x==b.x)
return a.y<b.y;
else
return a.x<b.x;
}
int main()
{
int l, r;
int i, j;
scanf("%d",&n);
for(i = 0; i < n; i++)
scanf("%d%d",&pot[i].x,&pot[i].y);
sort(pot,pot+n,cmp);
for(i = 0; i < n; i++)
{
l = pot[i].x,r = pot[i].y;
j = i;
while(j<n&&pot[j].x<=r)
{
if(pot[j].y>r)
r = pot[j].y;
j++;
}
printf("%d %d\n",l,r);
i = j-1;
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -