BZOJ3262 陌上花开
2014-11-23 16:55
281 查看
前人之述备矣、、、
树套树即BIT套treap 和 CQD分治 + BIT的方法都有了
于是就做好了233
View Code
树套树即BIT套treap 和 CQD分治 + BIT的方法都有了
于是就做好了233
/************************************************************** Problem: 3262 User: rausen Language: C++ Result: Accepted Time:1356 ms Memory:5888 kb ****************************************************************/ #include <cstdio> #include <algorithm> #define lowbit(x) x & -x using namespace std; const int N = 100005; struct data { int a, b, c, s, ans; }a , p ; inline bool sort1_cmp (const data &a, const data &b) { return a.a == b.a ? (a.b == b.b ? a.c < b.c : a.b < b.b) : a.a < b.a; } inline bool operator < (const data &a, const data &b) { return a.b == b.b ? a.c < b.c : a.b < b.b; } inline bool operator == (const data &a, const data &b) { return a.a == b.a && a.b == b.b && a.c == b.c; } inline bool operator != (const data &a, const data &b) { return !(a == b); } int tot, n, m, BIT[N << 1], ans ; inline int read() { int x = 0; char ch = getchar(); while (ch < '0' || '9' < ch) ch = getchar(); while ('0' <= ch && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x; } inline void update(int x, int del) { while (x <= m) BIT[x] += del, x += lowbit(x); } inline int query(int x) { int res = 0; while (x) res += BIT[x], x -= lowbit(x); return res; } void work(int l, int r) { if (l == r) return; int mid = l + r >> 1, i, j; work(l, mid), work(mid + 1, r); sort(p + l, p + mid + 1), sort(p + mid + 1, p + r + 1); for (i = l, j = mid + 1; j <= r; ++j) { for (; i <= mid && p[i].b <= p[j].b; ++i) update(p[i].c, p[i].s); p[j].ans += query(p[j].c); } for (j = l; j < i; ++j) update(p[j].c, -p[j].s); } int main() { int i, cnt; tot = read(), m = read(); for (i = 1; i <= tot; ++i) a[i].a = read(), a[i].b = read(), a[i].c = read(); sort(a + 1, a + tot + 1, sort1_cmp); for (cnt = 1, i = 1; i <= tot; ++i, ++cnt) if (a[i] != a[i + 1]) { p[++n] = a[i]; p .s = cnt; cnt = 0; } work(1, n); for (i = 1; i <= n; ++i) ans[p[i].ans + p[i].s - 1] += p[i].s; for (i = 0; i < tot; ++i) printf("%d\n", ans[i]); return 0; }
View Code
相关文章推荐
- 【BZOJ3262】 陌上花开
- BZOJ3262: 陌上花开
- 【bzoj 3262】陌上花开
- 【bzoj3262】陌上花开
- BZOJ3262 : 陌上花开
- BZOJ3262: 陌上花开
- [cdq分治] bzoj3262: 陌上花开
- BZOJ 3262 陌上花开
- 「BZOJ」「3262」陌上花开
- 【BZOJ】3262: 陌上花开
- bzoj3262: 陌上花开
- [BZOJ3262]陌上花开
- BZOJ3262 陌上花开
- 【BZOJ】【3262】陌上花开
- 【三维偏序】【分块】bzoj3262 陌上花开
- bzoj 3262 陌上花开
- bzoj 3262 陌上花开
- [BZOJ3262]陌上花开
- 陌上花开(bzoj 3262)
- BZOJ 3262 陌上花开