#include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <iostream> using namespace std; #define maxn 2222 #define pl c<<1 #define pr (c<<1)|1 #define lson tree[c].l,tree[c].mid,c<<1 #define rson tree[c].mid+1,tree[c].r,(c<<1)|1 int n; double pos[maxn]; //竖线 struct node { int l, r, mid; int cover; double len; }tree[maxn<<4]; struct segment { double l, r, h; int flag; bool operator < (segment a) const { return h < a.h; } }p[maxn]; double a, b, c, d; int cnt, m; void build_tree (int l, int r, int c) { tree[c].l = l, tree[c].r = r, tree[c].mid = (l+r)>>1; tree[c].cover = 0, tree[c].len = 0; if (l == r) return ; build_tree (lson); build_tree (rson); return ; } void push_up (int c) { if (tree[c].cover > 0) { tree[c].len = pos[tree[c].r+1] - pos[tree[c].l]; } else if (tree[c].l == tree[c].r) tree[c].len = 0; else tree[c].len = tree[pl].len + tree[pr].len; } void update (int l, int r, int c, int x, int y, int v) { if (l == x && r == y) { tree[c].cover += v; push_up (c); return ; } if (tree[c].mid >= y) { update (lson, x, y, v); } else if (tree[c].mid < x) { update (rson, x, y, v); } else { update (lson, x, tree[c].mid, v); update (rson, tree[c].mid+1, y, v); } push_up (c); return ; } void debug (int c) { cout << "l:" << tree[c].l << " r:" << tree[c].r << " len:" <<tree[c].len << " cover:" <<tree[c].cover <<endl; if (tree[c].l == tree[c].r) return ; debug (pl); debug (pr); } int main () { //freopen ("in", "r", stdin); int kase = 0; while (scanf ("%d", &n) == 1 && n) { cnt = 0; for (int i = 1; i <= n; i++) { scanf ("%lf%lf%lf%lf", &a, &b, &c, &d); p[cnt].l = a, p[cnt].r = c, p[cnt].h = b, p[cnt].flag = 1, pos[cnt] = a, cnt++; p[cnt].l = a, p[cnt].r = c, p[cnt].h = d, p[cnt].flag = -1, pos[cnt] = c, cnt++; } sort (pos, pos+cnt); sort (p, p+cnt); m = 0; pos[m++] = pos[0]; for (int i = 1; i < cnt; i++) { if (pos[i] != pos[i-1]) { pos[m++] = pos[i]; } } build_tree (0, m-1, 1); double ans = 0.0; for (int i = 0; i < cnt-1; i++) { int l = lower_bound (pos, pos+m, p[i].l) - pos; int r = lower_bound (pos, pos+m, p[i].r) - pos - 1; update (0, m-1, 1, l, r, p[i].flag); ans += tree[1].len * (p[i+1].h - p[i].h); } printf ("Test case #%d\n", ++kase); printf ("Total explored area: %.2f\n\n", ans); } return 0; }