首先一定要看到x + y + z = N这个条件,没看到就世界再见了。

  赢的人得分需要大于等于2,那么无非就是 (x, y), (x, z), (y, z), (x, y, z) 大于其他的点。但是考虑一下(x, y, z)均大于是不可能的,因为 x + y + z = N。(x, y) 和 (x, z) 这样的也不可能同时大于一个点,那么符合条件的点,只能满足(x, y), (x, z), (y, z)其中之一,所以我们把每一个点拆分为3个点,分别投影到xOy, xOz, yOz平面上,然后需要处理的就是在一个二维平面内的指定点有多少个小于它了。

  二位树状数组肯定是可以的,但是空间需要为 n^2 ,无疑不可行,那么我们考虑固定一维,把查询和插入操作混在一起,给查询操作和插入操作标号,因为在同一个横坐标出,查询操作优先,所以我们把查询操作标号为0,插入操作标号为1。这样打包make_pair(x, op, y, self_id),直接使用pair的运算符即可。

 #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define drep(i, a, b) for (int i = a; i >= b; i--)
#define travel(x) for (int i = G[x]; i; i = E[i].nx)
#define mp make_pair
#define pb push_back
#define clr(x) memset(x, 0, sizeof(x))
#define xx first
#define yy second
using namespace std;
typedef long long i64;
typedef pair<int, int> pii;
//********************************
const int maxn = ;
pair<int, pair<int, int> > sa[maxn];
pair<int, pair<int, int> > st[maxn];
pair<int, pair<int, pair<int, int> > > query[maxn << ];
int top;
int hsh[(maxn << ) * ], cd;
int ans[maxn];
int c[(maxn << ) * ];
void Insrt(int x, int v) {
while (x <= cd) {
c[x] += v;
x += x & -x;
}
}
int Query(int x) {
int ret();
while (x > ) {
ret += c[x];
x -= x & -x;
}
return ret;
}
int read() {
int l = , s(); char ch = getchar();
while (ch < '' || ch > '') { if (ch == '-') l = -; ch = getchar(); }
while (ch >= '' && ch <= '') { s = (s << ) + (s << ) + ch - ''; ch = getchar(); }
return l * s;
}
int main() {
int N, m, T; N = read(), m = read(), T = read();
rep(i, , m) sa[i].xx = read(), sa[i].yy.xx = read(), sa[i].yy.yy = read(), hsh[++cd] = sa[i].xx, hsh[++cd] = sa[i].yy.xx, hsh[++cd] = sa[i].yy.yy;
rep(i, , T) st[i].xx = read(), st[i].yy.xx = read(), st[i].yy.yy = read(), hsh[++cd] = st[i].xx, hsh[++cd] = st[i].yy.xx, hsh[++cd] = st[i].yy.yy;
sort(hsh + , hsh + + cd); cd = unique(hsh + , hsh + + cd) - (hsh + );
rep(i, , m) {
sa[i].xx = lower_bound(hsh + , hsh + + cd, sa[i].xx) - hsh;
sa[i].yy.xx = lower_bound(hsh + , hsh + + cd, sa[i].yy.xx) - hsh;
sa[i].yy.yy = lower_bound(hsh + , hsh + + cd, sa[i].yy.yy) - hsh;
}
rep(i, , T) {
st[i].xx = lower_bound(hsh + , hsh + + cd, st[i].xx) - hsh;
st[i].yy.xx = lower_bound(hsh + , hsh + + cd, st[i].yy.xx) - hsh;
st[i].yy.yy = lower_bound(hsh + , hsh + + cd, st[i].yy.yy) - hsh;
}
rep(i, , m) query[++top] = mp(sa[i].xx, mp(, mp(sa[i].yy.xx, i)));
rep(i, , T) query[++top] = mp(st[i].xx, mp(, mp(st[i].yy.xx, i)));
sort(query + , query + + top);
rep(i, , top) {
if (query[i].yy.xx == ) ans[query[i].yy.yy.yy] += Query(query[i].yy.yy.xx - );
else Insrt(query[i].yy.yy.xx, );
}
memset(c, , sizeof(c)); top = ;
rep(i, , m) query[++top] = mp(sa[i].xx, mp(, mp(sa[i].yy.yy, i)));
rep(i, , T) query[++top] = mp(st[i].xx, mp(, mp(st[i].yy.yy, i)));
sort(query + , query + + top);
rep(i, , top) {
if (query[i].yy.xx == ) ans[query[i].yy.yy.yy] += Query(query[i].yy.yy.xx - );
else Insrt(query[i].yy.yy.xx, );
}
memset(c, , sizeof(c)); top = ;
rep(i, , m) query[++top] = mp(sa[i].yy.xx, mp(, mp(sa[i].yy.yy, i)));
rep(i, , T) query[++top] = mp(st[i].yy.xx, mp(, mp(st[i].yy.yy, i)));
sort(query + , query + + top);
rep(i, , top) {
if (query[i].yy.xx == ) ans[query[i].yy.yy.yy] += Query(query[i].yy.yy.xx - );
else Insrt(query[i].yy.yy.xx, );
}
rep(i, , T) printf("%d\n", ans[i]);
return ;
}

最新文章

  1. Apache Kylin 部署之不完全指南
  2. 记一次惨痛的线上bug
  3. Win10 创建应用程序包及部署
  4. 前后台Json的转换
  5. python解析页面上json字段
  6. noj [1480] 懒惰的风纪委Elaine (多重背包)
  7. 新手引导-ugui
  8. Scrapy1.4爬取笑话网站数据,Python3.5+Django2.0构建笑话应用
  9. 解决DEDECMS Call to undefined function dede_htmlspecialchars()
  10. Mahout 算法
  11. urls控制器
  12. 用Java写hello world
  13. log4j.properties配置说明
  14. 原生ajax函数封装
  15. Python中*和**的作用(课堂小结)
  16. [Mac] How do I move a window whose title bar is off-screen?
  17. AtCoder Beginner Contest 066 B - ss
  18. Centos7修改默认启动级别(命令行,图形切换)
  19. linux 变量定义
  20. 使用tf.print()打印tensor内容

热门文章

  1. java 子类继承父类成员变量的隐藏、实现方法的重写
  2. cocos2d-x 3.x随机数
  3. CentOS下编译安装Apache2(新)
  4. PAT (Advanced Level) 1105. Spiral Matrix (25)
  5. 免费vpn:SoftEther VPN
  6. nginx配置文件【转载】
  7. 打开jsp页面自动加载多个Action的实现方法
  8. 实例:SSh结合Easyui实现Datagrid的分页显示
  9. 转:检查点(web_reg_find函数详解)
  10. Qt5:窗口背景色的设置