正文
增加 12 行删除 12 行
13 行未改动141516171819202122232425262728293031325 行未改动383940414243444546474849505152535455565791 行未改动14915015115215315415515615770 行未改动22822923023123223323423523625 行未改动2622632642652662672682692702712722732742752762772788 行未改动13 行未改动[P3810 【模板】三维偏序(陌上花开)](https://www.luogu.com.cn/problem/P3810)## 题意所谓偏序 ,就是指 **配备了部分排序关系的集合** ,也就是说按照我们自己定义的 " **顺序** " 排序。题目要求考虑 $a_i , b_i , c_i$ 三个限制 ,满足 $ a_j \leq a_i $ 且 $ b_j \leq b_i $ 且 $ c_j \leq c_i $ 且 $ j \ne i $ 然后问对于每个 $i$ 满足这样的 $j$ 有多少个~~感性理解~~## 解 :要满足三个限制 ,那就一个一个来 ,对 $a$ 先排序 , 其实可以发现 :**分治算法的实现 ,相当于是在对已满足 $a$ 有序的序列上做操作** ~~(发现不出来也没关系)~~$e.g:$原序 :```cppid1: 3 2 35 行未改动id2: 1 2 1id3: 2 3 2id1: 3 2 3```形象多了然后不断取 $mid$```cppa b cid2: 1 2 1 l- - - - - - - midid3: 2 3 2id1: 3 2 3 r```对于 $r$ 边的每个 $i$ 来说 ,要想求到比 $c_i$ 小的个数要满足另两个要求 :$$\begin{cases}1 . &a_j<a_i&\\91 行未改动int n,k,vis,cn;int ans[N],f[N],c[N];struct l{int a,b,c,id,cnt=1;bool operator==(const l& other) const {return a==other.a&&b==other.b&&c==other.c;}}a[N*4],tmp;70 行未改动}for(int i=l;i<=mid;i++){gai(a[i].c,-a[i].cnt);}// cout<<endl;}int main(){25 行未改动for(int i=1;i<=nn;i++){int cn=a[i].cnt;while(cn--)ans[f[a[i].id]]++;}for(int i=0;i<n;i++){cout<<ans[i]<<endl;}// for(int i=1;i<=n;i++){// while(a[i].cnt--){// cout<<a[i].a<<" "<<a[i].b<<" "<<a[i].c<<" ";//<<a[i].id<<" ";// cout<<f[a[i].id]<<endl;// }// }return 0;}8 行未改动13 行未改动141516171819202122232425262728293031325 行未改动383940414243444546474849505152535455565791 行未改动14915015115215315415515615770 行未改动22822923023123223323423523625 行未改动2622632642652662672682692702712722732742752762772788 行未改动13 行未改动[P3810 【模板】三维偏序(陌上花开)](https://www.luogu.com.cn/problem/P3810)## 题意所谓偏序 ,就是指 **配备了部分排序关系的集合** ,也就是说按照我们自己定义的 " **顺序** " 排序。题目要求考虑 $a_i , b_i , c_i$ 三个限制 ,满足 $ a_j \leq a_i $ 且 $ b_j \leq b_i $ 且 $ c_j \leq c_i $ 且 $ j \ne i $ 然后问对于每个 $i$ 满足这样的 $j$ 有多少个~~感性理解~~## 解 :要满足三个限制 ,那就一个一个来 ,对 $a$ 先排序 , 其实可以发现 :**分治算法的实现 ,相当于是在对已满足 $a$ 有序的序列上做操作** ~~(发现不出来也没关系)~~$e.g:$原序 :```cppid1: 3 2 35 行未改动id2: 1 2 1id3: 2 3 2id1: 3 2 3```形象多了然后不断取 $mid$```cppa b cid2: 1 2 1 l- - - - - - - midid3: 2 3 2id1: 3 2 3 r```对于 $r$ 边的每个 $i$ 来说 ,要想求到比 $c_i$ 小的个数要满足另两个要求 :$$\begin{cases}1 . &a_j<a_i&\\91 行未改动int n,k,vis,cn;int ans[N],f[N],c[N];struct l{int a,b,c,id,cnt=1;bool operator==(const l& other) const {return a==other.a&&b==other.b&&c==other.c;}}a[N*4],tmp;70 行未改动}for(int i=l;i<=mid;i++){gai(a[i].c,-a[i].cnt);}// cout<<endl;}int main(){25 行未改动for(int i=1;i<=nn;i++){int cn=a[i].cnt;while(cn--)ans[f[a[i].id]]++;}for(int i=0;i<n;i++){cout<<ans[i]<<endl;}// for(int i=1;i<=n;i++){// while(a[i].cnt--){// cout<<a[i].a<<" "<<a[i].b<<" "<<a[i].c<<" ";//<<a[i].id<<" ";// cout<<f[a[i].id]<<endl;// }// }return 0;}8 行未改动