/*
PROG: picture
LANG: C++
*/
#include
<
iostream
>
using
namespace
std;
const
int
maxn
=
21000
;
struct
node{
int
x1,x2,y;
bool
flag;
}lx[maxn],ly[maxn];
int
N;
void
init(){
freopen(
"
picture.in
"
,
"
r
"
,stdin);
scanf(
"
%d
"
,
&
N);
int
x1,y1,x2,y2;
for
(
int
i
=
0
;i
<
N;
++
i){
scanf(
"
%d%d%d%d
"
,
&
x1,
&
y1,
&
x2,
&
y2);
lx[i].x1
=
x1
+
10000
;
lx[i].x2
=
x2
+
10000
;
lx[i].y
=
y1
+
10000
;
lx[i].flag
=
1
;
lx[N
+
i].x1
=
x1
+
10000
;
lx[N
+
i].x2
=
x2
+
10000
;
lx[N
+
i].y
=
y2
+
10000
;
lx[N
+
i].flag
=
0
;
ly[i].x1
=
y1
+
10000
;
ly[i].x2
=
y2
+
10000
;
ly[i].y
=
x1
+
10000
;
ly[i].flag
=
1
;
ly[N
+
i].x1
=
y1
+
10000
;
ly[N
+
i].x2
=
y2
+
10000
;
ly[N
+
i].y
=
x2
+
10000
;
ly[N
+
i].flag
=
0
;
}
N
*=
2
;
}
int
cmp(
const
void
*
no1,
const
void
*
no2){
return
((node
*
)no1)
->
y
-
((node
*
)no2)
->
y;
}
int
oper(node
*
l){
qsort(l,N,
sizeof
(node),cmp);
int
cov[maxn];
memset(cov,
0
,
sizeof
(cov));
int
res
=
0
;
for
(
int
i
=
0
;i
<
N;
++
i)
if
(l[i].flag){
for
(
int
k
=
l[i].x1;k
<
l[i].x2;
++
k)
if
(
1
==++
cov[k])
res
++
;
}
else
for
(
int
k
=
l[i].x1;k
<
l[i].x2;
++
k)
if
(
0
==--
cov[k])
res
++
;
return
res;
}
void
work(){
int
ans
=
oper(lx)
+
oper(ly);
freopen(
"
picture.out
"
,
"
w
"
,stdout);
printf(
"
%d\n
"
,ans);
}
int
main()
{
init();
work();
return
0
;
}
/*
Executing
Test 1: TEST OK [0.000 secs, 3380 KB]
Test 2: TEST OK [0.011 secs, 3384 KB]
Test 3: TEST OK [0.011 secs, 3384 KB]
Test 4: TEST OK [0.000 secs, 3376 KB]
Test 5: TEST OK [0.011 secs, 3376 KB]
Test 6: TEST OK [0.011 secs, 3528 KB]
Test 7: TEST OK [0.022 secs, 3676 KB]
Test 8: TEST OK [0.000 secs, 3380 KB]
Test 9: TEST OK [0.022 secs, 3680 KB]
Test 10: TEST OK [0.011 secs, 3524 KB]
Test 11: TEST OK [0.130 secs, 3524 KB]
*/
posted on 2009-06-27 00:49
xfstart07 阅读(135)
评论(0) 编辑 收藏 引用