2022年10月14日
摘要: 该数据结构可以维护序列的前缀和 1. 单点修改,求区间和 #include <iostream> using namespace std; const int N=5e5+2; int n,tr[N]; int lowbit(int x){ return x&-x; } void add(int x 阅读全文
posted @ 2022-10-14 13:51 towboat 阅读(17) 评论(0) 推荐(0)
摘要: 并查集路径压缩中,维护某节点到根节点的距离(依题意为abs(x-y)%1000) 即 d[i] +=d[father[i] ] #include <iostream> #include <algorithm> #include <cmath> using namespace std; const i 阅读全文
posted @ 2022-10-14 13:34 towboat 阅读(16) 评论(0) 推荐(0)
摘要: 并查集判断图上是否有环 #include <iostream> #include <algorithm> using namespace std; const int N=1e5+4; int fa[N]; int find(int x){ return x==fa[x]?x:fa[x]=find( 阅读全文
posted @ 2022-10-14 13:05 towboat 阅读(8) 评论(0) 推荐(0)
摘要: 人跨台阶,每次能跨越的高度最大为D,给了每个台阶的高度,求最多走多高 解: 求一个数组里第一个x , a[x]>D ?处理一个前缀max ,然后查找 #include <iostream> #include <algorithm> using namespace std; const int N=2 阅读全文
posted @ 2022-10-14 08:31 towboat 阅读(22) 评论(0) 推荐(0)