随笔分类 - 《进阶指南》数据结构进阶
P3369 【模板】普通平衡树
摘要:直接抄WIDA的pbds板子 #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef pair<int, int
阅读全文
[Violet] 蒲公英(分块)
摘要:区间众数要求即有次数又要数字最小 #include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,int> PII; typedef long long ll; typede
阅读全文
P1502 窗口的星星(扫描线)
摘要:关键在把矩形框点转化为点的影响放大为矩形,此时转变为求一个点的权值最大 #include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,int> PII; typedef l
阅读全文
Interval GCD(单点修改线段树)
摘要:细节不少 //根据更相减损法gcd(x,y) = gcd(x,y-x) //推广到三项为gcd(x,y,z) = gcd(x,y-x,z-y) //可以推广到n项 #include<bits/stdc++.h> using namespace std; #define x first #define
阅读全文
Can you answer these queries III(单点修改线段树)
摘要:因为洛谷出现UE在acwing提交,输入格式略有修改 #include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,int> PII; typedef long long
阅读全文
[USACO03Open] Lost Cows(二分加树状数组)
摘要:#include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,int> PII; typedef long long ll; typedef unsigned long l
阅读全文
P3372 【模板】线段树 1
摘要:注意size信息应该存放在info里和tag运算,已经tag是表示子树未处理的信息 #include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,int> PII; typ
阅读全文
P3368 【模板】树状数组 2
摘要:#include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,int> PII; typedef long long ll; typedef unsigned long l
阅读全文
P10589 楼兰图腾(树状数组)
摘要:#include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,int> PII; typedef long long ll; typedef unsigned long l
阅读全文
食物链(并查集)
摘要:一开始默认为0,如果有捕食关系调整d[x] #include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,int> PII; typedef long long ll; t
阅读全文
[CEOI1999] Parity Game(并查集)
摘要:方法1:带权路径维护 本题核心:[a,b]之间有奇数个1转换为s[a-1]^s[b] = 1,从而转向并查集 #include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,
阅读全文
[NOI2002] 银河英雄传说(带权并查集)
摘要:带权并查集稍微注意下细节、 #include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,int> PII; typedef long long ll; typedef u
阅读全文
Supermarket(并查集)
摘要:考虑利润从高到底排序,优先把利润最高的填到最接近过期的空余位置 贪心证明:如果当前a[i]被填入而填入了比最靠近过期前面的位置显然不会更优,如果没有被填入而放了另一组方案利润更大,则把属于a[i]的位置换成a[i]一定更优,两者矛盾 #include<bits/stdc++.h> using nam
阅读全文
P1955 [NOI2015] 程序自动分析(并查集)
摘要:相等放并查集里,不等直接判断 #include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,int> PII; typedef long long ll; typedef
阅读全文