摘要: 树状数组 逆序对 #include <iostream> #include <cstring> #include <algorithm> #define int long long using namespace std; const int N = 5e5 + 10; int tr[N], ran 阅读全文
posted @ 2022-05-16 23:56 hzy0227 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 线段树 区间加,区间和 #include <iostream> #include <cstring> using namespace std; typedef long long ll; const int N = 1e5 + 10; ll w[N]; struct Node { int l, r; 阅读全文
posted @ 2022-05-16 23:43 hzy0227 阅读(14) 评论(0) 推荐(0) 编辑
摘要: E - Gold Transfer 树上倍增 + 贪心 由于 \(c_i>c_{p_i}\), 所以一定是把结点祖先的黄金采完才会采这个结点的,因此某个点有无黄金这个性质具有单调性,靠近根的一侧没有,靠近叶子的有,所以可以倍增查到某个结点上方离根最近的有黄金的结点,从该点开始采 由于一个点被采完才会 阅读全文
posted @ 2022-05-16 22:09 hzy0227 阅读(34) 评论(0) 推荐(0) 编辑
摘要: D - Inconvenient Pairs 思维 不方便的点对就是类似于,这种在同一行块或同一列块的两个点,他们的距离一定大于曼哈顿距离 其中红色为横向点对,紫色为纵向点对 所以可按 y 递增排序,找到每一个行块有多少个点,这一行块中的点对贡献为:\(\binom {cnt}2-\sum\bino 阅读全文
posted @ 2022-05-16 21:51 hzy0227 阅读(31) 评论(0) 推荐(0) 编辑