#include <iostream> #include <algorithm> using namespace std; #define MAX 5000 #define INF -10001 struct TNode { int left, right; int top; int sum; }; TNode T[MAX*12]; int map[MAX][4];// left right bolow high int temp1[MAX*2]; int temp2[MAX*2]; int index; long sum; int find(int* t,int v) { int low = 0, high = index-1; while(low <= high) { int mid = (low + high) >> 1; if(v == t[mid]) return mid; else if(v > t[mid]) low = mid + 1; else high = mid - 1; } return 0; } void build(int s, int t, int step) { T[step].left = s; T[step].right = t; T[step].top = INF; T[step].sum = 0; if(t -s <= 1) return; int mid = (s + t) >> 1; build(s, mid, step*2); build(mid, t, step*2+1); } void insert(int* temp, int s, int t, int step, int below, int high) { if(T[step].right -T[step].left <= 1) { if(below > T[step].top) { T[step].sum += 2*(temp[T[step].right] - temp[T[step].left]); T[step].top = high; } else if(high > T[step].top) T[step].top = high; return; } int mid = (T[step].left + T[step].right) >> 1; if(t <= mid) insert(temp, s, t, step*2, below, high); else if(mid <= s) insert(temp, s, t, step*2+1, below, high); else { insert(temp, s, mid, step*2, below, high); insert(temp, mid, t, step*2+1, below, high); } } void calculate(int step) { if(T[step].right -T[step].left <= 1) { if(T[step].sum != 0) sum += T[step].sum; return; } calculate(step*2); calculate(step*2+1); } int cmp1(const void* lhs, const void* rhs) { if( ((int*)lhs)[2] < ((int*)rhs)[2] ) return -1; return 1; } int cmp2(const void* lhs, const void* rhs) { if( ((int*)lhs)[0] < ((int*)rhs)[0] ) return -1; return 1; } int main() { int n; scanf("%d", &n); for(int i = 0; i < n; ++i) { scanf("%d%d%d%d",&map[i][0], &map[i][2], &map[i][1], &map[i][3]); temp1[index] = map[i][0]; temp2[index++] = map[i][2]; temp1[index] = map[i][1]; temp2[index++] = map[i][3]; } sort(temp1, temp1+2*n); index = 1; for(int i = 1; i < 2*n; ++i) // 去除重复点 if(temp1[i] != temp1[i-1]) temp1[index++] = temp1[i]; qsort(map, n, 4*sizeof(int),cmp1); build(0, index-1, 1); for(int i = 0; i < n; ++i) insert(temp1, find(temp1, map[i][0]), find(temp1, map[i][1]), 1, map[i][2], map[i][3]); calculate(1); sort(temp2, temp2+2*n); index = 1; for(int i = 1; i < 2*n; ++i) // 去除重复点 if(temp2[i] != temp2[i-1]) temp2[index++] = temp2[i]; qsort(map, n, 4*sizeof(int),cmp2); build(0, index-1, 1); for(int i = 0; i < n; ++i) insert(temp2, find(temp2,map[i][2]), find(temp2, map[i][3]), 1, map[i][0], map[i][1]); calculate(1); printf("%ld/n",sum); return 0; }