#include
<
stdio.h
>
#include
<
stdlib.h
>
#define
N 50001
struct
Node
{
int
a, b;
}
;
Node d[N];
int
n;
int
cmp(
const
void
*
a,
const
void
*
b )
{
Node
*
ta
=
(Node
*
)a;
Node
*
tb
=
(Node
*
)b;
if
( ta
->
a
==
tb
->
a )
return
ta
->
b
-
tb
->
b;
return
ta
->
a
-
tb
->
a;
}
int
main()
{
scanf(
"
%d
"
,
&
n);
for
(
int
i
=
0
; i
<
n;
++
i ) scanf(
"
%d%d
"
,
&
d[i].a,
&
d[i].b );
qsort( d, n,
sizeof
( d[
0
] ), cmp );
int
min
=
d[
0
].a, max
=
d[
0
].b;
for
(
int
i
=
1
; i
<
n;
++
i )
{
if
( d[i].a
>
max )
{
printf(
"
%d %d\n
"
, min, max );
min
=
d[i].a, max
=
d[i].b;
}
else
if
( d[i].b
>
max ) max
=
d[i].b;
}
printf(
"
%d %d\n
"
, min, max );
return
0
;
}
posted on 2008-10-29 23:01
Darren 阅读(220)
评论(0) 编辑 收藏 引用 所属分类:
图论