#include #include #include #include #include #include using namespace std; #define ss printf("orz\n"); #define maxn 2000 #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define getmid int mid=(l+r)>>1 int n,n1,n2; double xx[maxn],yy[maxn]; int tag[maxn]; double sum[maxn]; struct node { double x1,x2,y1,y2; }rec[maxn]; vectorg[maxn],g2[maxn]; void init() { for(int i=1;i<=n1;i++) g[i].clear(),g2[i].clear(); n1=n2=0; memset(sum,0.0,sizeof(sum)); memset(tag,0,sizeof(tag)); memset(xx,0.0,sizeof(xx)); memset(yy,0.0,sizeof(yy)); } void pushup(int rt,int l,int r) { if(tag[rt]>0) { sum[rt]=yy[r+1]-yy[l]; } else sum[rt]=sum[rt<<1]+sum[rt<<1|1]; } void update(int l,int r,int rt,int x,int y,int add) { //printf("%d %d %d %d %d\n",l,r,rt,x,y,rt); //system("pause"); if(x<=l&&r<=y) { tag[rt]+=add; pushup(rt,l,r); return; } getmid; if(x<=mid) update(lson,x,y,add); if(y>mid) update(rson,x,y,add); pushup(rt,l,r); } void change(int x) { for(int j=0;jmpx,mpy; for(int i=1;i<=n;i++) { scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2); rec[i]={x1,x2,y1,y2}; if(!mpy[y1]) { n2++;yy[n2]=y1;mpy[y1]=1; } if(!mpy[y2]) { n2++;yy[n2]=y2;mpy[y2]=1; } if(!mpx[x1]) { n1++;xx[n1]=x1;mpx[x1]=1; } if(!mpx[x2]) { n1++;xx[n1]=x2;mpx[x2]=1; } } sort(xx+1,xx+1+n1); sort(yy+1,yy+1+n2); for(int i=1;i<=n1;i++) mpx[xx[i]]=i; for(int i=1;i<=n2;i++) mpy[yy[i]]=i; node tmp; for(int i=1;i<=n;i++) { x1=rec[i].x1;x2=rec[i].x2; y1=1.0*mpy[rec[i].y1];y2=1.0*mpy[rec[i].y2]; tmp={y1,y2,1.0,0.0}; g[mpx[x1]].push_back(tmp); tmp={y1,y2,-1.0,0.0}; g2[mpx[x2]].push_back(tmp); } double ans=0; change(1); for(int i=2;i<=n1;i++) { ans+=(xx[i]-xx[i-1])*sum[1]; change(i); } cas++; printf("Test case #%d\n",cas); printf("Total explored area: %.2f\n\n",ans); //init(); } return 0; } /* 5 1.37 0.10 2.75 0.20 2.96 2.01 3.06 2.75 2.65 1.05 4.97 1.15 2.33 0.74 4.02 0.84 2.96 0.10 4.02 1.47 8 9.33 19.52 30.44 24.39 8.06 29.38 9.75 51.77 22.38 15.06 32.35 33.30 30.66 19.20 44.13 19.62 17.93 15.38 39.35 41.58 9.65 6.47 29.80 10.39 26.20 24.61 40.63 35.85 25.25 12.51 29.80 36.17 8 157.98 278.30 246.25 501.22 152.89 15.06 355.43 214.74 61.53 56.12 141.85 96.97 21.43 303.77 250.07 329.65 5.83 115.65 306.10 211.88 275.44 132.52 353.21 276.49 149.71 175.49 271.40 379.94 127.42 32.57 187.05 282.22 */