POJ3277:City Horizon
摘要:——problem:求平面上矩形的面积,重复的只算一次。矩形的一边和X轴重合。——solution:离散化+线段树——url:http://poj.org/problem?id=3277比赛的时候先离散化试了下,超时。于是只能再写线段树,结果线段树写撮了。注意:1、40000个矩形,边大概有80000多个,线段树的数组至少要开到80000×3=240000。2、所有矩形先按从小到大排序。这样插入的时候不必判断已经插入矩形的高度,直接插就可以了。3、注意面积会超过int的范围,要开long long。代码:第一个代码矩形没有排序。于是node有三个域,h记录高度(如果左右子树的高度不同
阅读全文
posted @
2011-04-02 21:39
风也轻云也淡
阅读(315)
推荐(1)
EOJ:Cleaning Shifts
摘要:Cleaning ShiftsTime Limit: 1000MSMemory Limit: 65536KTotal Submits: 75Accepted: 29DescriptionFarmer John's cows, pampered since birth, have reached new heights of fastidiousness. They now require their barn to be immaculate. Farmer John, the most obliging of farmers, has no choice but hire some
阅读全文
posted @
2011-02-05 21:07
风也轻云也淡
阅读(261)
推荐(0)