本文共 1801 字,大约阅读时间需要 6 分钟。
1 // #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 // #include 16 using namespace std; 17 #define clc(a,b) memset(a,b,sizeof(a)) 18 #define inf 0x3f3f3f3f 19 #define lson l,mid,rt<<1 20 #define rson mid+1,r,rt<<1|1 21 const int N = 1100; 22 const int MOD = 1e9+7; 23 #define LL long long 24 #define mi() (l+r)>>1 25 double const pi = acos(-1); 26 27 // inline int r() { 28 // int x=0,f=1;char ch=getchar(); 29 // while(ch>'9'||ch<'0') {if(ch=='-') f=-1;ch=getchar();} 30 // while(ch>='0'&&ch<='9') { x=x*10+ch-'0';ch=getchar();}return x*f; 31 // } 32 int n; 33 double hashh[N<<2]; 34 double sum[N<<2]; 35 int color[N<<2]; 36 struct Edge{ 37 double x1,x2,y; 38 int flag; 39 bool operator < (const Edge &a) const{ 40 return y >1; 49 if(hashh[mid]==x) return mid; 50 else if(hashh[mid] mid) update(mid+1,r,rt<<1|1,x,y,f); 70 else { 71 update(l,mid,rt<<1,x,mid,f); 72 update(mid+1,r,rt<<1|1,mid+1,y,f); 73 } 74 pushdown(rt,l,r); 75 } 76 int main(){ 77 // int n; 78 while(scanf("%d",&n)){ 79 if(n==0) 80 break; 81 clc(color,0); 82 clc(sum,0); 83 double x1,x2,y1,y2; 84 for(int i=1;i<=n;i++){ 85 scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2); 86 e[i*2-1].x1=e[i*2].x1=x1; 87 e[i*2-1].x2=e[i*2].x2=x2; 88 e[i*2-1].y=y1;e[i*2].y=y2; 89 e[i*2-1].flag=1;e[i*2].flag=-1; 90 hashh[i*2-1]=x1;hashh[i*2]=x2; 91 } 92 sort(e+1,e+1+2*n); 93 sort(hashh+1,hashh+1+2*n); 94 double ans=0; 95 for(int i=1;i<=2*n;i++){ 96 int l=b_s(e[i].x1),r=b_s(e[i].x2)-1; 97 // cout<<"l:"< <<" "<<"r:"< <
转载于:https://www.cnblogs.com/ITUPC/p/5643275.html