void create_data(){ int i,less,gre; less = 0; bit.res(N); for(i = 1; i < N; ++i){ while(pts[less].x < pts[i].x){ bit.update(pts[less].y,1); ++less; } data[i][0] = bit.query(pts[i].y+1,N); if(pts[i].y) data[i][3] = bit.query(0,pts[i].y-1); data[i][7] = bit.query(pts[i].y,pts[i].y); data[i][6] = i-less; } bit.res(N); gre = N-1; for(i = N-2; i >= 0; --i){ while(pts[gre].x > pts[i].x){ bit.update(pts[gre].y,1); --gre; } data[i][1] = bit.query(pts[i].y+1,N); if(pts[i].y) data[i][2] = bit.query(0,pts[i].y-1); data[i][5] = bit.query(pts[i].y,pts[i].y); data[i][4] = gre-i; } }
int query(int x) { return x*x1.query(x) + x0.query(x); }