class BIT: #0-indexed def __init__(self, n): self.size = n self.tree = [0]*(n+1) self.depth = n.bit_length() self.n0 = 1< 0: s += self.tree[i] i -= i & -i return s def query(self,l,r): #a_l + ... + a_r 閉区間 return self.get_sum(r) - self.get_sum(l-1) def add(self, i, x): i += 1 while i <= self.size: self.tree[i] += x i += i & -i # self.element[i] += x #def get(self,i): return element[i] def bisect_left(self,w): #和が w 以上になる最小の index #w が存在しない場合 self.size を返す if w <= 0: return 0 x,k = 0,self.n0 for _ in range(self.depth): k >>= 1 if x+k <= self.size and self.tree[x+k] < w: w -= self.tree[x+k] x += k return x """ C++ の std::map ぽいデータ構造 座標圧縮は前提 n: 取りうる最大値(最小値は 0) self.dic を dict に取り換えることでメモリ節約できる """ class stdmap: def __init__(self, n): self.size = n+1 self.keys = set() self.B = BIT(n+1) #存在すれば 1、しないなら 0 self.dic = [0]*(n+1) # 値域 def __contains__(self, k): return k in self.keys def insert(self,a,b): # 値 a に b を上書き if a not in self.keys: self.B.add(a,1) self.keys.add(a) self.dic[a] = b def remove(self,a): # a を取り除く self.keys.remove(a) self.B.add(a,-1) def lower_bound(self,k): # k 以上の最小のkeyを求める return self.B.bisect_left(self.B.get_sum(k)) def kth_key(self,k): # k 番目に小さい元のkeyを求める return self.B.bisect_left(k) def kth_value(self,k): # k 番目に小さい元のmap先を求める return self.dic[self.B.bisect_left(k)] def prev_key(self,k): #一個前の元のkeyを求める idx = self.B.get_sum(k) assert idx != 0 return self.B.bisect_left(idx-1) def next_key(self,k): idx = self.B.get_sum(k) assert idx != self.size return self.B.bisect_left(idx+1) def __getitem__(self,item): return self.dic[item] # coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline n = int(input()) M = map(int,read().split()) xyxy = [*zip(M,M,M,M)] def solve(xy,n): MAX = 2*10**4+10 mp = stdmap(MAX) mp.insert(MAX,0) mp.insert(0,1<<31) res = [0]*n for i in range(n): x,y = xy[i] x0,y0 =x,y k = mp.lower_bound(x) v1 = mp[k] v2 = mp[mp.next_key(k)] if y <= v2: continue val = (y-v2)*(x-k) while y > v1: x = k v2 = v1 k1 = mp.prev_key(k) #print(k,k1) mp.remove(k) k = k1 v1 = mp[k] val += (y-v2)*(x-k) #print(x,y,k,k1,v2,val) if not x0 in mp: mp.insert(x0,y0) res[i] = val return res ans = [0]*n """ a = [(1,10),(1,12),(1,11),(1,15)] print(solve(a,4)) """ res1 = solve([(x2,y2) for x1,y1,x2,y2 in xyxy],n) res2 = solve([(-x1,y2) for x1,y1,x2,y2 in xyxy],n) res3 = solve([(x2,-y1) for x1,y1,x2,y2 in xyxy],n) res4 = solve([(-x1,-y1) for x1,y1,x2,y2 in xyxy],n) for i in range(n): ans[i] += res1[i]+res2[i]+res3[i]+res4[i] print("\n".join(map(str,ans)))