求三维偏序的模板 :

 //Author : 15owzLy1
//luogu3810.cpp
//2018 12 25 16:31:58
#include <cstdio>
#include <cstring>
#include <algorithm>
static char buf[],*p1=buf,*p2=buf;
inline char get_char() {
return p1==p2&&(p2=(p1=buf)+fread(buf,,,stdin),p1==p2)?EOF:*p1++;
}
inline int in() {
int x=;char c=get_char();
while(c<''||c>'')c=get_char();
while(c>=''&&c<='')x=(x<<)+(x<<)+(c^), c=get_char();
return x;
}
template<typename T>
inline void out(T &x) {
int cnt=;
static char s[];
do s[cnt++]=x%+; while(x/=);
while(cnt--) putchar(s[cnt]);
putchar('\n');
} const int N = (int)1e5+;
struct Triple {
int x, y, z, val, ans;
}a[N], tmp[N];
int n, k, ans[N]; inline bool cmp(const Triple &x, const Triple &y) {
if(x.x==y.x) return x.z==y.z?x.y<y.y:x.z<y.z;
return x.x<y.x;
} struct BinaryIndexedTree {
int t[N<<];
inline void insert(int p, int del) {for(;p<=k;p+=p&-p)t[p]+=del;}
inline int ask(int p) {int ret=;for(;p;p-=p&-p)ret+=t[p];return ret;}
}bit; void cdq(int l, int r) {
if(l==r) return ;
int mid=(l+r)>>;
cdq(l, mid); cdq(mid+, r);
int i=l, j=mid+, k=l;
while(i<=mid&&j<=r)
if(a[i].z<=a[j].z)
bit.insert(a[i].y, a[i].val), tmp[k++]=a[i++];
else
a[j].ans+=bit.ask(a[j].y), tmp[k++]=a[j++];
for(int p=j;p<=r;p++) a[p].ans+=bit.ask(a[p].y);
for(int p=l;p<i;p++) bit.insert(a[p].y, -a[p].val);
if(i<=mid) std::copy(a+i, a+mid+, tmp+k);
if(j<=r) std::copy(a+j, a+r+, tmp+k);
std::copy(tmp+l, tmp+r+, a+l);
} int main() {
int nn=in();
k=in();
for(int i=;i<=nn;i++)
tmp[i]=(Triple){in(), in(), in(), , }; std::sort(tmp+, tmp++nn, cmp);
for(int i=, cnt=;i<=nn;i++, cnt++)
if(tmp[i].x!=tmp[i+].x||tmp[i].y!=tmp[i+].y||tmp[i].z!=tmp[i+].z)
a[++n]=tmp[i], a[n].val=cnt, cnt=;
cdq(, n);
for(int i=;i<=n;i++) ans[a[i].ans+a[i].val-]+=a[i].val;
for(int i=;i<nn;i++) out(ans[i]);
return ;
}

CDQ分治求不知道多少维偏序 (持续更新 ]的更多相关文章

  1. CDQ分治嵌套模板:多维偏序问题

    CDQ分治2 CDQ套CDQ:四维偏序问题 题目来源:COGS 2479 偏序 #define LEFT 0 #define RIGHT 1 struct Node{int a,b,c,d,bg;}; ...

  2. Educational Codeforces Round 41 967 E. Tufurama (CDQ分治 求 二维点数)

    Educational Codeforces Round 41 (Rated for Div. 2) E. Tufurama (CDQ分治 求 二维点数) time limit per test 2 ...

  3. CDQ分治学习笔记(三维偏序题解)

    首先肯定是要膜拜CDQ大佬的. 题目背景 这是一道模板题 可以使用bitset,CDQ分治,K-DTree等方式解决. 题目描述 有 nn 个元素,第 ii 个元素有 a_iai​.b_ibi​.c_ ...

  4. hdu5618(cdq分治求三维偏序)

    题意:给n(n<=100000)个点,坐标为(xi,yi,zi)(1<=xi,yi,zi<=100000),定义一个点A比一个点B小,当且仅当xA<=xB,yA<=yB, ...

  5. BOI2007 Mokia | cdq分治求二维点数模板

    题目链接:戳我 也没什么,其实主要就是为了存一个求二维坐标上矩形内点的个数的模板.为了之后咕咕咕地复习使用 不过需要注意的一点是,树状数组传x的时候可千万不要传0了!要不然会一直死循环的...qwqw ...

  6. SPOJ:Another Longest Increasing Subsequence Problem(CDQ分治求三维偏序)

    Given a sequence of N pairs of integers, find the length of the longest increasing subsequence of it ...

  7. CDQ分治求前缀和

    #include<bits/stdc++.h> using namespace std; ; int n,a_tot,q_tot,ans[N]; ]; struct query { int ...

  8. oracle运维(持续更新)

    目录 简单命令使用 进入SQL*Plus 退出SQL*Plus 在sqlplus下得到帮助信息 显示表结构命令 DESCRIBE SQL*Plus 中的编辑命令 调用外部系统编辑器 运行命令文件 关于 ...

  9. MySQL日常运维操作---持续更新

    1.查看当前连接数: 这些参数都是什么意思呢? Threads_cached ##mysql管理的线程池中还有多少可以被复用的资源 Threads_connected ##打开的连接数 Threads ...

随机推荐

  1. Spring Cloud:Security OAuth2 自定义异常响应

    对于客户端开发或者网站开发而言,调用接口返回有统一的响应体,可以针对性的设计界面,代码结构更加清晰,层次也更加分明. 默认异常响应 在使用 Spring Security Oauth2 登录和鉴权失败 ...

  2. Linux启动时间优化-内核和用户空间启动优化实践

    关键词:initcall.bootgraph.py.bootchartd.pybootchart等. 启动时间的优化,分为两大部分,分别是内核部分和用户空间两大部分. 从内核timestamp 0.0 ...

  3. DependencyInjection源码解读之ServiceProvider

    var services = new ServiceCollection(); var _serviceProvider = services.BuildServiceProvider(); serv ...

  4. CI/CD持续集成/持续部署 敏捷开发

    敏捷软件开发(英语:Agile software development),又称敏捷开发,是一种从1990年代开始逐渐引起广泛关注的一些新型软件开发方法,是一种应对快速变化的需求的一种软件开发能力.它 ...

  5. 【问题解决方案】ImportError: No module named 'openpyxl'/‘xlrd’

    背景: 在jupyter notebook to_excle: 运行将dataframe保存为excel文件 df.to_excel('dataframe.xlsx') 时报错openpyxl rea ...

  6. laravel 远程一对多实例

    /** * 关联楼宇推荐书关联表 * 远程一对一 */ public function buildingPanos() { return $this->hasManyThrough( 'App\ ...

  7. NOIP2002普及组复赛B 选数

    题目链接:https://ac.nowcoder.com/acm/contest/230/B 题目大意: 略 分析: DFS模板题. 代码如下: #include <bits/stdc++.h& ...

  8. Python——模块——时间模块

    1.time模块 (1)时间戳 >>> time.time() 1472016249.393169 (2)将时间戳转换成当前时间元祖 time.localtime()time.gmt ...

  9. /usr/bin/ld: .build_release/tools/alignment_tools.o: undefined reference to symbol 'omp_get_thread_num@@OMP_1.0'

    问题:/usr/bin/ld: .build_release/tools/alignment_tools.o: undefined reference to symbol 'omp_get_threa ...

  10. 第六十五天 js操作

    1.闭包 // 函数的嵌套定义,定义在内部的函数都称之为 闭包 // 1.一个函数要使用另一个函数的局部变量 // 2.闭包会持久化包裹自身的函数的局部变量 // 3.解决循环绑定 function ...