HDU_1556_Color the ball
2013-05-20 18:44
288 查看
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<string> #include<queue> using namespace std; int c[100005],n; int lowbit(int x) { return x&-x; } int sum(int x) { int ret=0; while(x>0) { ret+=c[x];x-=lowbit(x); } return ret; } void add(int x,int d) { while(x<=n) { c[x]+=d;x+=lowbit(x); } } int main() { int a,b,i,j,k; while(~scanf("%d",&n)&&n) { for(i=1;i<=n;++i) c[i]=0; for(i=1;i<=n;++i) { scanf("%d%d",&a,&b); add(a,1); add(b+1,-1); } for(i=1;i<n;++i) printf("%d ",sum(i)); printf("%d\n",sum(n)); } return 0; }
相关文章推荐
- HDU - 1556 Color the ball 区间更新
- Color the ball [HDU 1556]
- hdu 1556 Color the ball (扫描线+树状数组)
- HDU 1556 Color the ball【树状数组】
- HDU 1556 Color the ball
- hdu 1556 Color the ball
- HDU 1556 Color the ball【线段树】
- HDU - 1556 Color the ball (一维树状数组 + 区间修改 + 单点求值)
- hdu 1556 color the ball
- HDU 1556 Color the ball(树状数组,基础,气球染色问题)
- hdu 1556 Color the ball
- HDU-1556-Color the ball
- hdu 1556 Color the ball
- HDU 1556 Color the ball - from lanshui_Yang
- HDU 1556 color the ball
- HDU-1556-Color the ball-线段树+区间更新+单点查询
- HDU - 1556——Color the ball
- HDU 1556 Color the ball(线段树)
- HDU 1556 Color the ball(树状数组)
- hdu 1556 Color the ball(线段树的另一种应用)