[BZOJ 1818] CQOI2010 内部白点
来源:互联网 发布:apache 设置访问目录 编辑:程序博客网 时间:2024/06/08 18:29
处理方式酷似上一题…简化版?hhhhhhhhh
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;typedef long long LL;const int N = 100010 ;inline void read(int &x){ char c; bool f = 0; while ((c = getchar()) < '0' || c > '9') if (c == '-') f = 1; for (x = c - '0'; (c = getchar()) >= '0' && c <= '9'; x = x * 10 + c - '0'); if (f) x = -x;}struct Data{ int x, y; inline bool operator < (const Data & b) const { return y < b.y || (y == b.y && x < b.x); }}p[N];int tx[N], ty[N], cx, cy;int cnt[N], n;bool vis[N];namespace BIT{ int c[N]; inline void add(int p, int v) { while (p <= cx) c[p] += v, p += p & -p; } inline int ask(int p) { int ret = c[p]; while (p -= p & -p) ret += c[p]; return ret; }}int main(){ read(n); for (int i = 1; i <= n; ++i) { read(p[i].x), read(p[i].y); tx[i] = p[i].x, ty[i] = p[i].y; } sort(tx + 1, tx + n + 1); cx = unique(tx + 1, tx + n + 1) - tx - 1; sort(ty + 1, ty + n + 1); cy = unique(ty + 1, ty + n + 1) - ty - 1; sort(p + 1, p + n + 1); for (int i = 1; i <= n; ++i) { p[i].x = lower_bound(tx + 1, tx + cx + 1, p[i].x) - tx; p[i].y = lower_bound(ty + 1, ty + cy + 1, p[i].y) - ty; cnt[p[i].x]++; } using namespace BIT; int ans = n, cur = 1; p[n + 1].y = -1; while (cur <= n) { int l = cur; while (p[l].y == p[l + 1].y) ans += ask(p[l + 1].x - 1) - ask(p[l].x), l++; while (cur <= l) { int x = p[cur++].x; cnt[x]--; if (!vis[x] && cnt[x]) vis[x] = 1, add(x, 1); else if (vis[x] && !cnt[x]) add(x, -1); } } printf("%d\n", ans); return 0;}
0 0
- [BZOJ 1818] CQOI2010 内部白点
- BZOJ 1818 [Cqoi2010]内部白点
- BZOJ 1818 Cqoi2010 内部白点 树状数组
- 1818: [Cqoi2010]内部白点
- 1818: [Cqoi2010]内部白点
- bzoj 1818: [Cqoi2010]内部白点 (扫描线+线段树)
- 【bzoj1818】[Cqoi2010]内部白点
- 【bzoj1818】[Cqoi2010]内部白点
- [BZOJ1818] [Cqoi2010]内部白点
- bzoj1818[Cqoi2010]内部白点
- 【bzoj1818】[Cqoi2010]内部白点
- bzoj1818: [Cqoi2010]内部白点
- bzoj1818: [Cqoi2010]内部白点
- 【bzoj1818】 CQOI2010内部白点 树状数组计数
- BZOJ1818: [Cqoi2010]内部白点 树状数组+离散化
- [BZOJ1818][Cqoi2010]内部白点(扫描线+线段树)
- BZOJ1818 [Cqoi2010]内部白点 扫描线/线段求交
- 【bzoj 1816】: [Cqoi2010]扑克牌
- 封装测试一段代码的运行时间
- N1:Stack Queue DFS BFS
- 记录一些博客和网站
- koa2快速搭建api服务器-创建入口文件及koa实例
- 【翻译+原创】Deep Learning Face Representation from Predicting 10,000 Classes 论文笔记
- [BZOJ 1818] CQOI2010 内部白点
- Crawler
- Python中麻烦的缩进
- Android实现点击两次返回键退出
- jquery 数组 添加元素
- [LeetCode]44 通配符的匹配
- 51Nod 1459 迷宫游戏 (dijkstra)
- Android 之Loader(加载器)
- 字符、字节的概念及其区别