返回顶部
摘要: 下面是一种正确的CDQ分治,使用线段树来实现,渐进复杂度到达要求。但是貌似CDQ分治在解决偏序问题的时候要尽可能使用树状数组。小心不要把i和j写反了。下面这个写法虽然没有WA,但是TLE了,这个非常麻烦。事实上是因为有很多多余的操作影响了常数,比如多余的排序、没有用的修改、询问。当然这个线段树也可以 阅读全文
posted @ 2019-09-05 20:32 Inko 阅读(164) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/problem/content/201/ 要注意这次的数论分块里面是有一个上界n的,对k进行分块的时候l和r都不能超过n。 cpp include using namespace std; typedef long long ll; ll s1(ll n 阅读全文
posted @ 2019-09-05 17:44 Inko 阅读(136) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/problem/content/258/ cpp include using namespace std; typedef long long ll; const int N = 600010; int trie[N 24][2], latest[N 2 阅读全文
posted @ 2019-09-05 17:22 Inko 阅读(111) 评论(0) 推荐(0) 编辑
摘要: ``` include define mid ((l+r) 1) using namespace std; typedef long long ll; const int MAXN = 200000 + 5; int T[MAXN], tcnt; int cnt[MAXN cnt[v] cnt[u] 阅读全文
posted @ 2019-09-05 16:55 Inko 阅读(91) 评论(0) 推荐(0) 编辑