/* [NKP'05] North-western wind by: Jan Kuipers */ using namespace std; #include #include class point { public: int x,y; point () {} point (int _x, int _y) { x=_x, y=_y; } }; bool smaller1 (point a, point b) { return a.x!=b.x ? a.xb.y; } bool smaller2 (point a, point b) { return a.y!=b.y ? a.y>b.y : a.x long long sort (vector &p, smallerfunction smaller) { if (p.size()==1) return 0; vector p1(p.begin(), p.begin()+p.size()/2); vector p2(p.begin()+p.size()/2, p.end()); long long res=sort(p1,smaller)+sort(p2,smaller), tmp=0; int i1=0, i2=0, i=0; while (i1> runs; while (runs--) { int N,x,y; cin >> N; vector p(N); for (int i=0; i> x >> y; p[i] = point(x,y); } sort(p, smaller1); cout << (long long) N*(N-1)/2 - sort(p, smaller2) << endl; } return 0; }