上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 22 下一页
摘要: 好像又叫meet in the middle 所谓双向搜索,简而言之,就是先搜一半,再搜另一半,然后试着将两半拼合。 具体看例题,你将会有更深的体会。 例题一:世界冰球锦标赛 网址:https://www.luogu.com.cn/problem/P4799 如果洛谷很卡的话,还有一个网址:http 阅读全文
posted @ 2020-03-23 13:06 syzf2222 阅读(542) 评论(0) 推荐(1) 编辑
摘要: 思路显然,就是对每一个颜色建一棵LCT(有没有想过颜色多了怎么办) 讲一讲我从这道题里面get到的小技能。 判断连通性: if(findroot(x)==findroot(y))return true; else return false; 还有一个比较坑的地方就是它修改颜色的时候可能跟以前相同,这 阅读全文
posted @ 2020-03-19 13:43 syzf2222 阅读(112) 评论(0) 推荐(1) 编辑
摘要: 这没什么好讲的,都是套路。 话说我的代码在本地跑得贼慢,我还以为会TLE,然后发现时限有4s 看代码: #include<bits/stdc++.h> using namespace std; const int maxn=5*1e6+10; int f[maxn],a[maxn],n,m; int 阅读全文
posted @ 2020-03-17 17:25 syzf2222 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 请点这里,我实在是懒得复制粘贴了。 阅读全文
posted @ 2020-03-17 16:47 syzf2222 阅读(77) 评论(0) 推荐(0) 编辑
摘要: 重构树的版子题,当然也可以用倍增或二分答案。 看代码: #include<bits/stdc++.h> using namespace std; const int maxn=1e6+10; struct node{ int x,y,z; }edge[maxn]; int n,m,q,cnt; in 阅读全文
posted @ 2020-03-17 14:48 syzf2222 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 简单的可持久化。 是刚学主席树的练手好题!! #include<bits/stdc++.h> using namespace std; const int maxn=2*1e6+10; struct node{ int l,r,val; }tr[maxn]; int n,cnt,tot,root[m 阅读全文
posted @ 2020-03-17 11:39 syzf2222 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 这是树上待修莫队的裸题。 可是我已开始应为吧cmp写错了TLE成30,呜呜…… 看代码: #include<bits/stdc++.h> using namespace std; #define int long long const int maxn=1e5+10; int n,m,q,a[max 阅读全文
posted @ 2020-03-16 14:11 syzf2222 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 这题在修改的时候略有不同,应当减去之前的贡献再加上此时的贡献。 就像这样: void add(int x){ now=now+2*cnt[a[x]]+1; cnt[a[x]]++; } void del(int x){ cnt[a[x]]--; now=now-2*cnt[a[x]]-1; } 那么 阅读全文
posted @ 2020-03-11 22:12 syzf2222 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 这几乎就是莫队板子。 是否互不相同等价于判断 now==q[i].r-q[i].l+1 。 看代码: #include<bits/stdc++.h> using namespace std; const int maxn=1e5+10; int n,m,a[maxn],cnt[maxn],ans[m 阅读全文
posted @ 2020-03-11 22:09 syzf2222 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 如果要学习莫队算法请另寻别处。 但是这里可以为您提供高质量的练习题配代码。 代码如下: #include<bits/stdc++.h> using namespace std; const int maxn=1e6+10; struct node{ int l,r,bl,br,id; }q[maxn 阅读全文
posted @ 2020-03-11 22:07 syzf2222 阅读(198) 评论(0) 推荐(0) 编辑
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 22 下一页