#include <stdio.h> #include <cstring> #include <algorithm> #include <iostream> using namespace std; const int maxn=1001; struct point { int x,y,z; } p[15001]; int c[maxn][maxn]; int s[15001]; int cmp(point a,point b) { if(a.z!=b.z) return a.z<b.z; else if(a.y!=b.y) return a.y<b.y; return a.x<b.x; } inline int lowbit(int x) { return x&(-x); } void update(int x,int y,int p) { for(int i=x; i<maxn; i+=lowbit(i)) for(int j=y; j<maxn; j+=lowbit(j)) c[i][j]+=p; } int sum(int x,int y) { int ans=0; for(int i=x; i>0; i-=lowbit(i)) for(int j=y; j>0; j-=lowbit(j)) ans+=c[i][j]; return ans; } int main() { int n,x,y,z; while(scanf("%d",&n)==1) { for(int i=0;i<=n;i++) s[i]=0; memset(c,0,sizeof(c)); for(int i=0; i<n; i++) { scanf("%d %d %d",&x,&y,&z); p[i].x=x,p[i].y=y,p[i].z=z; } sort(p,p+n,cmp); for(int i=0; i<n; i++) { s[sum(p[i].x+1,p[i].y+1)]++; update(p[i].x+1,p[i].y+1,1); } for(int i=0; i<n-1; i++) printf("%d ",s[i]); printf("%d\n",s[n-1]); } return 0; }
HOJ 2678 Stars
最新推荐文章于 2016-11-23 22:41:24 发布