#include using namespace std; const int N = 100010; struct ScanLine { double y1, y2, x; int mark; bool operator<(const ScanLine &t) const { return x < t.x; } } line[N << 1]; struct Node { int l, r; int cnt; double len; } tr[N << 2]; double b[N << 2]; // 离散化数组 void pushup(int u) { if (tr[u].cnt) tr[u].len = b[tr[u].r + 1] - b[tr[u].l]; else tr[u].len = tr[u << 1].len + tr[u << 1 | 1].len; } void build(int u, int l, int r) { tr[u].l = l, tr[u].r = r; if (l == r) return; int mid = (l + r) >> 1; build(u << 1, l, mid); build(u << 1 | 1, mid + 1, r); } void modify(int u, int l, int r, int v) { if (l <= tr[u].l && r >= tr[u].r) { tr[u].cnt += v; pushup(u); return; } int mid = (tr[u].l + tr[u].r) >> 1; if (l <= mid) modify(u << 1, l, r, v); if (r > mid) modify(u << 1 | 1, l, r, v); // 更新统计信息 pushup(u); } int main() { #ifndef ONLINE_JUDGE freopen("247.in", "r", stdin); #endif ios::sync_with_stdio(false), cin.tie(0); int n, T = 1; while (cin >> n, n) { // 多组测试数据,记得清空 memset(tr, 0, sizeof tr); memset(b, 0, sizeof b); for (int i = 1; i <= n; i++) { double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; b[2 * i - 1] = y1; b[2 * i] = y2; line[2 * i - 1] = {y1, y2, x1, 1}; line[2 * i] = {y1, y2, x2, -1}; } n *= 2; sort(line + 1, line + 1 + n); sort(b + 1, b + 1 + n); int tot = unique(b + 1, b + 1 + n) - b - 1; build(1, 1, tot - 1); double res = 0; for (int i = 1; i < n; i++) { int L = lower_bound(b + 1, b + 1 + tot, line[i].y1) - b; int R = lower_bound(b + 1, b + 1 + tot, line[i].y2) - b; modify(1, L, R - 1, line[i].mark); res += tr[1].len * (line[i + 1].x - line[i].x); } printf("Test case #%d\n", T++); printf("Total explored area: %.2lf\n\n", res); } return 0; }