锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
#include聽
<
stdio.h
>
#include聽
<
stdlib.h
>
#include聽
<
string
.h
>
int
聽
const
聽inf
=
聽
1
<<
29
;
int
聽n;
struct
聽Point
{
聽聽聽聽
int
聽Lx,聽Ly,聽Rx,聽Ry;
}
;
Point聽pnt[
16
];
int
聽聽need[
16
],聽dp[
1
<<
15
][
15
],聽color[
16
];

void
聽init()
{
聽聽聽聽
for
(聽
int
聽i
=
聽
0
;聽i
<=
聽n;聽
++
i聽)聽need[i]
=
聽
0
;
聽聽聽聽
聽聽聽聽
for
(聽
int
聽i
=
聽
0
;聽i
<
聽n;聽
++
i聽)
{
聽聽聽聽聽聽聽聽
for
(
int
聽j
=
聽
0
;聽j
<
聽n;聽
++
j聽)
{
聽聽聽聽聽聽聽聽聽聽聽聽
if
(聽i
==
聽j聽)聽
continue
;

聽聽聽聽聽聽聽聽聽聽聽聽
if
(聽pnt[j].Ry
<=
聽pnt[i].Ly聽
&&
聽pnt[j].Lx
<
聽pnt[i].Rx聽)
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽need[i]
|=
聽(
1
<<
j);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}
void
聽solve()
{
聽聽聽聽
for
(聽
int
聽i
=
聽
0
;聽i
<
聽(
1
<<
n);聽
++
i聽)
聽聽聽聽聽聽聽聽
for
(
int
聽j
=
聽
0
;聽j
<
聽n;聽
++
j聽)聽dp[i][j]
=
聽inf;
聽聽聽聽dp[
0
][
0
]
=
聽
0
;
聽聽聽聽
for
(聽
int
聽i
=
聽
0
;聽i
<
聽n;聽
++
i聽)
聽聽聽聽聽聽聽聽
if
(聽need[i]
==
聽
0
聽)聽dp[
1
<<
i][i]
=
聽
1
;
聽聽聽聽
聽聽聽聽
for
(聽
int
聽s
=
聽
0
;聽s
<
聽(
1
<<
n);聽
++
s聽)
{
聽聽聽聽聽聽聽聽
for
(聽
int
聽i
=
聽
0
;聽i
<
聽n;聽
++
i聽)
{
聽聽聽聽聽聽聽聽聽聽聽聽
if
(聽(聽s
&
聽(
1
<<
i)聽)
==
聽
0
聽)聽
continue
;

聽聽聽聽聽聽聽聽聽聽聽聽
for
(聽
int
聽j
=
聽
0
;聽j
<
聽n;聽
++
j聽)
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if
(聽s
&
聽(
1
<<
j)聽)聽
continue
;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if
(聽(s
&
聽need[j])
!=
聽need[j]聽)聽
continue
;

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if
(聽dp[s][i]
+
聽(聽color[i]
!=
聽color[j]聽)
<
聽dp[s
|
(
1
<<
j)][j]聽)
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[s
|
(
1
<<
j)][j]
=
聽dp[s][i]
+
聽(聽color[i]
!=
聽color[j]聽);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
聽聽聽聽}
聽聽聽聽
int
聽ans
=
聽inf;
聽聽聽聽
for
(聽
int
聽i
=
聽
0
;聽i
<
聽n;聽
++
i聽)
聽聽聽聽聽聽聽聽
if
(聽dp[(
1
<<
n)
-
1
][i]
<
聽ans聽)聽ans
=
聽dp[(
1
<<
n)
-
1
][i];
聽聽聽聽printf(
"
%d\n
"
,聽ans聽);
}
int
聽main()
{
聽聽聽聽
int
聽test;
聽聽聽聽scanf(
"
%d
"
,
&
test聽);

聽聽聽聽
while
(聽test
--
聽)
{
聽聽聽聽聽聽聽聽scanf(
"
%d
"
,
&
n聽);

聽聽聽聽聽聽聽聽
for
(聽
int
聽i
=
聽
0
;聽i
<
聽n;聽
++
i聽)
{
聽聽聽聽聽聽聽聽聽聽聽聽scanf(
"
%d%d%d%d
"
,聽
&
pnt[i].Ly,聽
&
pnt[i].Lx,聽
&
pnt[i].Ry,聽聽
&
pnt[i].Rx聽);
聽聽聽聽聽聽聽聽聽聽聽聽scanf(
"
%d
"
,聽color
+
聽i聽);
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽init();
聽聽聽聽聽聽聽聽solve();
聽聽聽聽}
聽聽聽聽
聽聽聽聽
return
聽
0
;
}
#include聽
<
iostream
>
#include聽
<
algorithm
>
using
聽
namespace
聽std;
#define
聽N聽2110
struct
聽Tree
{
聽聽聽聽
double
聽length,聽len;
聽聽聽聽
int
聽聽聽聽cnt;
聽聽聽聽Tree()
{聽length
=
聽
0
;聽cnt
=
聽
0
;聽}
聽聽聽聽
void
聽init()
{聽length
=
聽
0
;聽cnt
=
聽
0
;聽len
=
聽
0
;聽}
}
tb[
10100
];
double
聽x1[N],聽y1[N],聽x2[N],聽y2[N],聽xx[N],聽idx[N];
int
聽pos,聽n;

struct
聽Line
{
聽聽聽聽
double
聽y,聽x1,聽x2;
聽聽聽聽
bool
聽type;
}
line[N];

bool
聽
operator
<
(聽Line聽
const
&
聽a,聽Line聽
const
&
聽b聽)
{
聽聽聽聽
return
聽a.y
<
聽b.y;聽}
聽聽聽聽
inline聽
int
聽bsearch(聽
double
聽value聽)
{
聽聽聽聽
int
聽low
=
聽
1
,聽high
=
聽pos
+
聽
1
;
聽聽聽聽
while
(聽low
<=
聽high聽)
{
聽聽聽聽聽聽聽聽
int
聽mid
=
聽(low
+
聽high)
>>
聽
1
;
聽聽聽聽聽聽聽聽
if
(聽idx[mid]
>
聽value聽)聽high
=
聽mid
-
聽
1
;
聽聽聽聽聽聽聽聽
else
聽
if
(聽idx[mid]
<
聽value聽)聽low
=
聽mid
+
聽
1
;
聽聽聽聽聽聽聽聽
else
聽
return
聽mid;聽}
}
inline聽
void
聽update(聽
int
聽rt,聽
int
聽l,聽
int
聽r聽)
{
聽聽聽聽
if
(聽tb[rt].cnt聽)聽tb[rt].length
=
聽idx[r]
-
聽idx[l];
聽聽聽聽
else
聽
if
(聽l
+
聽
1
==
聽r聽)聽tb[rt].length
=
聽
0
;
聽聽聽聽
else
聽tb[rt].length
=
聽tb[rt
<<
1
].length
+
聽tb[(rt
<<
1
)
+
1
].length;
}
inline聽
void
聽update2(聽
int
聽rt,聽
int
聽l,聽
int
聽r聽)
{
聽聽聽聽
if
(聽tb[rt].cnt
>
聽
1
聽)聽tb[rt].len
=
聽idx[r]
-
聽idx[l];
聽聽聽聽
else
聽
if
(聽tb[rt].cnt
==
聽
1
聽)聽tb[rt].len
=
聽tb[rt
<<
1
].length
+
聽tb[(rt
<<
1
)
+
1
].length;
聽聽聽聽
else
聽tb[rt].len
=
聽tb[rt
<<
1
].len
+
聽tb[(rt
<<
1
)
+
1
].len;聽}
void
聽deal(聽
int
聽rt,聽
int
聽l,聽
int
聽r,聽
int
聽a,聽
int
聽b,聽
int
聽t聽)
{
聽聽聽聽
if
(聽a
<=
聽l聽
&&
聽b
>=
聽r聽)
{
聽聽聽聽聽聽聽聽tb[rt].cnt
+=
聽t;聽update(聽rt,聽l,聽r聽);聽update2(聽rt,聽l,聽r聽);聽聽
return
;聽}
聽聽聽聽聽聽聽聽
聽聽聽聽
int
聽mid
=
聽(l
+
聽r)
>>
聽
1
;
聽聽聽聽
if
(聽a
<
聽mid聽)聽deal(聽rt
<<
聽
1
,聽l,聽mid,聽a,聽b,聽t);
聽聽聽聽
if
(聽b
>
聽mid聽)聽deal(聽(rt
<<
1
)
+
聽
1
,聽mid,聽r,聽a,聽b,聽t聽);
聽聽聽聽
聽聽聽聽update(聽rt,聽l,聽r聽);聽update2(聽rt,聽l,聽r聽);
}
int
聽main()
{
聽聽聽聽
int
聽test
=
聽
1
;
聽聽聽聽scanf(
"
%d
"
,
&
test聽);
聽聽聽聽
while
(聽test
--
聽)
{
聽聽聽聽聽聽聽聽scanf(
"
%d
"
,
&
n);
聽聽聽聽聽聽聽聽
for
(聽
int
聽i
=
聽
0
;聽i
<=
聽
10000
;聽
++
i聽)聽tb[i].init();
聽聽聽聽聽聽聽聽
for
(聽
int
聽i
=
聽
0
;聽i
<
聽n;聽
++
i聽)聽
{
聽聽聽聽聽聽聽聽聽聽聽聽scanf(
"
%lf%lf%lf%lf
"
,聽x1
+
聽i,聽y1
+
聽i,聽x2
+
聽i,聽y2
+
聽i聽);
聽聽聽聽聽聽聽聽聽聽聽聽line[
2
*
i].y
=
聽y1[i];聽聽聽line[
2
*
i].x1
=
聽x1[i];聽
聽聽聽聽聽聽聽聽聽聽聽聽line[
2
*
i].x2
=
聽x2[i];聽聽line[
2
*
i].type
=
聽
0
;
聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽xx[
2
*
i]
=
聽x1[i];聽xx[
2
*
i
+
聽
1
]
=
聽x2[i];
聽聽聽聽聽聽聽聽聽聽聽聽line[
2
*
i
+
1
].y
=
聽y2[i];聽聽line[
2
*
i
+
1
].x1
=
聽x1[i];
聽聽聽聽聽聽聽聽聽聽聽聽line[
2
*
i
+
1
].x2
=
聽x2[i];聽line[
2
*
i
+
1
].type
=
聽
1
;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽sort(聽xx,聽xx
+
聽
2
*
聽n聽);聽聽聽聽sort(聽line,聽line
+
聽
2
*
聽n聽);
聽聽聽聽聽聽聽聽pos
=
聽
1
;聽idx[
1
]
=
聽xx[
0
];
聽聽聽聽聽聽聽聽
for
(聽
int
聽i
=
聽
1
;聽i
<
聽
2
*
聽n;聽
++
i聽)
聽聽聽聽聽聽聽聽
if
(聽xx[i]
!=
聽xx[i
-
1
]聽)聽idx[
++
pos]
=
聽xx[i];
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
double
聽ans
=
聽
0
;
聽聽聽聽聽聽聽聽
for
(聽
int
聽i
=
聽
0
;聽i
<
聽
2
*
聽n
-
聽
1
;聽
++
i聽)
{
聽聽聽聽聽聽聽聽聽聽聽聽
int
聽u
=
聽bsearch(聽line[i].x1聽),聽v
=
聽bsearch(聽line[i].x2聽);
聽聽聽聽聽聽聽聽聽聽聽聽
if
(聽line[i].type
==
聽
0
聽)聽deal(聽
1
,聽
1
,聽pos,聽u,聽v,聽
1
聽);
聽聽聽聽聽聽聽聽聽聽聽聽
else
聽deal(聽
1
,聽
1
,聽pos,聽u,聽v,聽
-
1
聽);
聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽ans
+=
聽tb[
1
].len
*
聽(聽line[i
+
1
].y
-
聽line[i].y聽);
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽printf(
"
%.2lf\n
"
,聽ans聽);
聽聽聽聽}
聽聽聽聽
聽聽聽聽
return
聽
0
;
}
4銆丠efei 鍚堣偉璧涘尯錛堜腑鍥界瀛︽妧鏈ぇ瀛︼級
緗戠粶閫夋嫈璧涙棩鏈燂細2009騫?鏈?鏃?14:00-17:00
鐜板満璧涙棩鏈燂細2009騫?0鏈?0鏃ワ綖11鏃?br>http://acm.ustc.edu.cn/
5銆丯ingbo 瀹佹嘗璧涘尯錛堟禉姹熷ぇ瀛﹀畞娉㈢悊宸ュ闄級
緗戠粶閫夋嫈璧涙棩鏈燂細2009騫?鏈?2鏃?br>鐜板満璧涙棩鏈燂細2009騫?0鏈?7鏃ワ綖18鏃?br>http://acmasia09.nit.net.cn/
6銆丣akarta 闆呭姞杈捐禌鍖猴紙鍗板凹 Binus University錛?br>鐜板満璧涙棩鏈燂細2009騫?0鏈?1鏃?br>http://icpc.ewubd.edu/
7銆丮anila 椹凹鎷夎禌鍖猴紙鑿插緥瀹?Ateneo de Manila University錛?br>鐜板満璧涙棩鏈燂細2009騫?0鏈?2鏃ワ綖23鏃?br>http://www.math.admu.edu.ph/acm/
8銆丼hanghai 涓婃搗璧涘尯錛堜笢鍗庡ぇ瀛︼級
緗戠粶閫夋嫈璧涙棩鏈燂細2009騫?鏈?0鏃?12:00-17:00)
鐜板満璧涙棩鏈燂細2009騫?0鏈?4鏃ワ綖25鏃?br>http://acm.dhu.edu.cn
9銆丠sinchu 鏂扮璧涘尯錛堜氦閫氬ぇ瀛︼級
鎶ュ悕鎴鏃ユ湡錛?009騫?鏈?9鏃?br>鐜板満璧涙棩鏈燂細2009騫?0鏈?0鏃ワ綖31鏃?br>http://icpc2009.nctu.edu.tw/
10銆乄uhan 姝︽眽璧涘尯錛堟姹夊ぇ瀛︼級
緗戠粶閫夋嫈璧涙棩鏈燂細2009騫?0鏈?
鐜板満璧涙棩鏈燂細2009騫?0鏈?1鏃ワ綖11鏈?鏃?br>http://acm.whu.edu.cn/
11銆丄mritapuri 闃垮閲屽鏅噷璧涘尯錛堝嵃搴?Amrita Vishwa Vidyapeetham, Amritapuri Campus錛?br>鐜板満璧涙棩鏈燂細2009騫?1鏈?鏃?br>http://icpc.amrita.ac.in/
12銆丳huket 鏅悏宀涜禌鍖猴紙娉板浗 Prince of Songkla University, Phuket Campus錛?br>鎶ュ悕鎴鏃ユ湡錛?009騫?鏈?0鏃?br>鐜板満璧涙棩鏈燂細2009騫?1鏈?鏃ワ綖4鏃?br>http://www.acmicpc-thailand.org/
13銆丼eoul 棣栧皵璧涘尯錛堥煩鍥?Korea Advanced Institute of Science and Technology錛?br>鎶ュ悕鎴鏃ユ湡錛?009騫?鏈?1鏃?br>鐜板満璧涙棩鏈燂細2009騫?1鏈?鏃ワ綖6鏃?br>http://acm.kaist.ac.kr/
14銆乀ehran 寰烽粦鍏拌禌鍖猴紙浼婃湕 Sharif University of Technology錛?br>鐜板満璧涙棩鏈燂細2009騫?1鏈?鏃?br>http://sharif.edu/~acmicpc
15銆乀okyo 涓滀含璧涘尯錛堟棩鏈棭紼葷敯澶у錛?br>鐜板満璧涙棩鏈燂細2009騫?1鏈?鏃ワ綖8鏃?br>http://www.waseda.jp/assoc-icpc2009/en/index.html
http://cm.baylor.edu/welcome.icpc
浜氭床楂樻牎鍙粍闃熷弬鍔犲叏閮ㄥ崄浜斾釜璧涘尯鐨勯閫夎禌錛屼絾姣忎綅鍙傝禌閫夋墜鏈澶氬彧鑳芥敞鍐屽弬鍔?strong>涓や釜璧涘尯鐨勯閫夎禌銆?/p>
Keep on attempting!
灝濊瘯錛?/font>灝濊瘯錛屽啀灝濊瘯錛?/font>
Bravery
Never lose heart, be sure you are brave enough to face failure!
鍕囨暍鍦拌法榪?font face="Batang, 바탕, serif">澶?/font>璐?font face="Batang, 바탕, serif">錛屾垚鍔熷氨鍦ㄥ墠鏂廣?/font>
Cooperation
It is teamwork, you are not alone.
鎴戜滑鏄綔涓轟竴涓洟闃熶竴璧峰姫鍔涚殑銆?/font>
Diligence
Working hard, and bear abundant fruit.
涓浠借曡橈紝涓浠芥敹鑾鳳紒
Enjoy
Enjoy the work.
鎬佸害鍐沖畾涓鍒囷紝ACM-ICPC鏄揩涔愮殑錛?/font>
Facility
Facility in programming promise the champion.
鎵庡疄鐨勭紪紼嬭兘鍔涙槸澶哄啝鐨勬湁鍔涙敮鏌便?/font>
Galaxy
ACM-ICPC is just a galaxy.
緹よ嫳鑱氫細鏂規樉鐜嬭呮湰鑹層?/font>
Honor
It is great honor to try the contest.
ACM錛屼竴嬈℃棤鎮旂殑灝濊瘯錛屼竴孌電簿褰╃殑浜虹敓銆?/font>
Intelligence
Who is the cleverest?
涓鍦烘櫤鎱х殑杈冮噺銆?/font>
Judger
Judge in the contest as God in the world.
瑁佸垽浜?/font>ACM錛屽氨濡傚悓涓婂笣浜庝笘鐣屻?
Knotty
The way to champion is knotty.
鍐犲啗涔嬭礬閾烘弧鑽嗘銆?/font>
Lucky
Luck permits!
ACM錛屼竴鍒囩殕鏈夊彲鑳姐?/font>
Magic
Magic ideas work wonder.
鐏靛厜涓闂殑鐬棿錛屾垜浠煡閬?/font>ACM鍘熸潵鏄竴鍦虹璇濈殑鎸戞垬銆?/font>
Naturally
It’s naturally for us to win the ACM.
鐢ㄦ垜浠殑鑳滃埄鏉ヨ癄閲婃浘緇忕殑鍔姏錛岃壈杈涘拰鍧氫俊錛?/font>
Objective
To achieve the objective is always in the next second…
鎴栬鎴戜滑鏇村ぇ鐨勬敹鑾峰湪浜庢垜浠箣闂磋涓嬬墷涓嶅彲鐮寸殑瑾撹█…
Parents
On this long hard load, we wonder, we hesitate. It’s your power push me forward, my parents!
鎴戠埍浣犱滑錛佷翰鐖辯殑鐖哥埜濡堝~
Quality
The quality of a contest should be focus on person rather than skill.
鎬繪湁鏇撮棯浜殑鏄熻鐪間簬娣遍們鐨勫絀?#8230;
Schedule
There always exists something out of schedule.
浠庢椂闂磋〃涓婃垜浠湅瑙佸偓淇冪湅瑙佽禌紼嬭繕鏈夋皵鐞冦佽繕鏈夋湭鏉?#8230;
Team
The honor belongs to our team! Come on!
涓鍒囨潵鑷?/font>ACM鐨勫鏈猴紝鎰熸縺浠栬鎴戜滑鐩歌瘑銆?/font>
University
Shang hai Jiaotong University records my growing.
涔熻鏈変竴澶╂濇簮婀栦細鍐犱笂鎴戠殑鍚嶅瓧~
Victory
Two for victory~
姘歌繙璁板緱瀵圭潃闀滃ご鎴戜滑鐨勭瑧閭d箞鐏跨儌銆?/font>
Wing
We came to the fore, flew without wings.
鏄ぉ浣胯祴浜堜簡鎴戦緲旂殑緲呰唨錛屾垜鐢ㄥ畠涓捐搗浜?/font>ACM鐨勫鏉?/font>
X
We fight against the x!
闈㈠鏈煡錛屾槸鎴戜滑鐫佸ぇ濂藉鐨勫弻鐪鹼紝涔熸槸鎴戜滑鏃犵晱鐨勫悜鍓嶏紝濂旇蕩榪滄柟銆?/font>
Yesterday
Yesterday once more.
鍥炵湼閭d簺杈夌厡錛屽敮鏈夊繕鍗存墠鑳藉嚡鏃嬶紒
Zero
All begin with zero…
鎴戜滑绔欏湪鏂扮殑璧風偣涓婏紝鏁磋寰呭彂錛?/font>