陌上花開(三維偏序)(cdq分治)

2022-03-03 17:51:39 字數 539 閱讀 6288

其實就是三位偏序的模板,cdq分治入門題。

學習cdq分治請看__stdcall大佬的部落格:傳送門

排序來維護第一層,cdq維護一層,樹狀陣列維護一層,然後就沒有啦qwqwq

#include#include#include#include#include#define maxn 100010

using namespace std;

int n,k,cnt;

int ans[maxn],tree[maxn<<1];

struct nodenode[maxn],now[maxn];

inline bool cmp1(struct node x,struct node y)

for(int j=l;j}int main()

cdq(1,cnt);

for(int i=1;i<=cnt;i++) ans[now[i].ans+now[i].sum-1]+=now[i].sum;

for(int i=0;ireturn 0;

}

三維偏序(陌上花開)

這是一道模板題 可以使用bitset,cdq分治,k dtree等方式解決。有 n個元素,第 i個元素有 ai bi ci 三個屬性,設 f i 表示滿足 aj ai 且 bj bi 且 cj ci 的 j 的數量。對於 d 0,n 求 f i d 的數量 輸入格式 第一行兩個整數 n k,分別表示...

三維偏序 陌上花開

有 n 個元素,每個元素有三個屬性 a i b i c i 定義 f i 為滿足 a j a i 且 b j b i 且 c j c i 的 j 的個數 ans i sum f j i 求所有的 ans i 陌上花開,心憂梓桑。cdq 分治模板題 首先以 a 為關鍵字排序,省略一維 再以 b 為關鍵...

三維偏序 cdq

luogu 3810 就是將逆序對轉化到了三維上去 原理等我寒假再補 第一維sort解決 第二維並歸排序 cdq 解決 第三維樹狀陣列 luogu judger enable o2 include include include include using std sort const int ma...