Atlantis
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <limits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define ll long long
#define MT(a,b) memset(a,b,sizeof(a))
const int maxn=2E3+5;
const int ONF=-0x3f3f3f3f;
const int INF=0x3f3f3f3f;
double lsh[600];
struct node1{
double sum;
int cnt;
}qwe[maxn<<2];
struct node2{
double stx,edx,y;
int val;
}edge[maxn<<2];
bool cmp(node2 a,node2 b){
return a.y<b.y;
}
void push_up(int l,int r,int root){
if (qwe[root].cnt) qwe[root].sum=lsh[r+1]-lsh[l];
else if (l==r) qwe[root].sum=0;
else qwe[root].sum=qwe[root<<1].sum+qwe[root<<1|1].sum;
}
void update(int l,int r,int ql,int qr,int root,int val){
if (l==ql&&r==qr){
qwe[root].cnt+=val;
push_up(l,r,root);
return;
}
int mid=(l+r)>>1;
if (qr<=mid) update(l,mid,ql,qr,root<<1,val);
else if (ql>mid) update(mid+1,r,ql,qr,root<<1|1,val);
else{
update(l,mid,ql,mid,root<<1,val);
update(mid+1,r,mid+1,qr,root<<1|1,val);
}
push_up(l,r,root);
}
int main(){
int n;
int turn=0;
double x1,y1,x2,y2;
while (~scanf ("%d",&n)){
if (n==0) break;
turn++;
int cnt=1;
for (int i=1;i<=n;i++){
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
edge[cnt]={x1,x2,y1,1},lsh[cnt++]=x1;
edge[cnt]={x1,x2,y2,-1},lsh[cnt++]=x2;
}
sort(edge+1,edge+cnt,cmp);
sort(lsh+1,lsh+cnt);
int len =unique(lsh+1,lsh+cnt)-lsh;
double ans=0;
for (int i=1;i<cnt;i++){
int l=lower_bound(lsh+1,lsh+len,edge[i].stx)-lsh;
int r=lower_bound(lsh+1,lsh+len,edge[i].edx)-lsh-1;
update(1,len,l,r,1,edge[i].val);
ans+=(edge[i+1].y-edge[i].y)*qwe[1].sum;
}
printf("Test case #%d\nTotal explored area: %.2lf\n\n",turn,ans);
}
return 0;
}