水一下
#include#define lson l, m, rt<<1#define rson m+1, r, rt<<1|1using namespace std;const int MAXN = 111111;int sum[MAXN<<2];int n;void push_down(int rt, int len){ if(sum[rt] == 0) return; sum[rt<<1] += sum[rt]; sum[rt<<1|1] += sum[rt]; sum[rt] = 0;}void update(int L, int R, int l, int r, int rt){ if(L <= l && r <= R) { sum[rt]++; return; } push_down(rt, r - l + 1); int m = (l + r) >> 1; if(m >= L) update(L, R, lson); if(m < R) update(L, R, rson);}void query(int l, int r, int rt){ if(l == r) { printf("%d%c", sum[rt], l == n? '\n':' '); return; } push_down(rt, r - l + 1); int m = (l + r) >> 1; query(lson); query(rson);}int main(){// freopen("in.txt", "r", stdin); while(~scanf("%d", &n) && n) { memset(sum, 0, sizeof(sum)); int m = n; while(m--) { int a, b; scanf("%d%d", &a, &b); update(a, b, 1, n, 1); } query(1, n, 1); } return 0;}