标题效果:特定y值在升序一些点。一个点的定义level值点的数目对于其左下,每个请求level多少分。
思维:因为y值它是按升序。所以分的差距仅仅是推断x值相比之前的大。就用树状数组维护。
CODE:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define MAX 50000 using namespace std; int cnt,fenwick[MAX]; int ans[MAX]; inline void Initialize(); inline void Fix(int x); inline int GetSum(int x); int main() { while(scanf("%d",&cnt) != EOF) { Initialize(); for(int x,y,i = 1;i <= cnt; ++i) { scanf("%d%d",&x,&y); x++; Fix(x); ans[GetSum(x)]++; } for(int i = 1;i <= cnt; ++i) printf("%d ",ans[i]); } return 0; } inline void Initialize() { memset(fenwick,0,sizeof(fenwick)); memset(ans,0,sizeof(ans)); } inline void Fix(int x) { for(;x < MAX;x += x&-x) fenwick[x]++; } inline int GetSum(int x) { int re = 0; for(;x;x -= x&-x) re += fenwick[x]; return re; }
版权声明:本文博客原创文章。博客,未经同意,不得转载。