这题,简直丧心病狂了。

大意是给你一个环上一些覆盖的区间,让你求总覆盖长度。

非常坑的点是这个区间因为是个环,所以可能逆时针给你,也可能顺时针给你,你特别要注意。那么区分顺时针和逆时针的方法

就是,题目中的一句关键:每个区间都小于180.根据这个判断就可以。还有一个要注意的地方就是,他可能在一个角度中的不能分度搞你。这题我是彻底服了。把我坑的底朝天。后来管理BZOJ要的数据才明白是怎么回事。。。。太弱弱了。。。。

Code:

 #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream> using namespace std; int N;
int pos = ,Ans = ,tot = ; struct data{
int flag;
int sum;
}w[]; int q[];
int tail = ;
bool cmp(data a,data b);
int main(){
scanf("%d",&N);
for(int i = ;i <= N;++ i){
int x1,y1,z1,x2,y2,z2;
scanf("%d%d%d%d%d%d",&x1,&y1,&z1,&x2,&y2,&z2);
if(x1 > x2){//so silly..caocao
if(x1 - x2 >= ){
++ tot;
w[tot].sum = x1*+y1*+z1;
w[tot].flag = ;
++ tot;
w[tot].sum = *;
w[tot].flag = ;
++ tot;
w[tot].sum = ;
w[tot].flag = ;
++ tot;
w[tot].sum = x2*+y2*+z2;
w[tot].flag = ;
}
else{
++ tot;
w[tot].sum = x2*+y2*+z2;
w[tot].flag = ;
++ tot;
w[tot].sum = x1*+y1*+z1;
w[tot].flag = ;
}
}
else if(x2 > x1){
if(x2 - x1 >= ){
++ tot;
w[tot].sum = x2*+y2*+z2;
w[tot].flag = ;
++ tot;
w[tot].sum = *;
w[tot].flag = ;
++ tot;
w[tot].sum = ;
w[tot].flag = ;
++ tot;
w[tot].sum = x1*+y1*+z1;
w[tot].flag = ;
}
else{
++ tot;
w[tot].sum = x1*+y1*+z1;
w[tot].flag = ;
++ tot;
w[tot].sum = x2*+y2*+z2;
w[tot].flag = ;
}
}
else if(x2 == x1){
if(y2 == y1){
if(z1 > z2){
++ tot;
w[tot].sum = x1*+y2*+z2;
w[tot].flag = ;
++ tot;
w[tot].sum = x1*+y2*+z1;
w[tot].flag = ;
}
else{
++ tot;
w[tot].sum = x1*+y2*+z1;
w[tot].flag = ;
++ tot;
w[tot].sum = x1*+y2*+z2;
w[tot].flag = ;
}
}
else{
if(y1 > y2){
++ tot;
w[tot].sum = x1*+y2*+z2;
w[tot].flag = ;
++ tot;
w[tot].sum = x2*+y1*+z1;
w[tot].flag = ;
}
else{
++ tot;
w[tot].sum = x1*+y1*+z1;
w[tot].flag = ;
++ tot;
w[tot].sum = x2*+y2*+z2;
w[tot].flag = ;
} }
}
}
sort(w+,w+tot+,cmp); while(true){
++ pos;
if(pos > tot)
break;
if(w[pos].flag == ){
q[++ tail] = w[pos].sum;
}
else if(w[pos].flag == ){
if(tail == ){
Ans += w[pos].sum - q[tail];
-- tail;
}
else
-- tail;
}
}
printf("%d",Ans);
return ;
} bool cmp(data a,data b){
return a.sum < b.sum;
}

Have a Look

05-11 20:41