上一页 1 2 3 4 5 6 7 8 ··· 29 下一页
摘要: 区间求和,单点修改,单点取模。 单点取模直接暴力取模,存一个max,如果max<mod,那么无需取模。 #include<cstdio> #include<iostream> using namespace std; const int N=100005; typedef long long ll; 阅读全文
posted @ 2021-09-26 14:40 dfydn 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 将每个颜色看成点,将小木棒看成边,如果能连成,即为一笔画问题。 首先要注意判断图是否连通,然后统计奇点个数。 注意map的一个优化!! 未优化(90pts T一个点) #include<cstdio> #include<iostream> #include<map> #include<cstring 阅读全文
posted @ 2021-09-17 19:30 dfydn 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 反向建图。 时间复杂度呢?(不会) #include<cstdio> #include<iostream> #include<cstring> using namespace std; const int N=100005; int n,m,tot; int head[N],a[N]; struct 阅读全文
posted @ 2021-09-11 21:51 dfydn 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 倒序处理,并查集维护连续性。 #include<cstdio> #include<iostream> using namespace std; const int N=10000005; int n,m,p,q; int color[N],f[N]; int find(int x){ if(x==f 阅读全文
posted @ 2021-09-11 21:38 dfydn 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 注意看是不是一个并查集的祖先: f[i]==i #include<cstdio> #include<iostream> using namespace std; typedef long long ll; const int N=10005; int n,m,w; int c[N],d[N],f[N 阅读全文
posted @ 2021-09-11 20:14 dfydn 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 01染色,取染色个数较小的。 注意图不一定联通。 #include<cstdio> #include<iostream> #include<cstring> using namespace std; const int N=100005; int n,m; int head[N]; int c[N] 阅读全文
posted @ 2021-09-11 19:48 dfydn 阅读(24) 评论(0) 推荐(0) 编辑
摘要: #include<cstdio> #include<iostream> #include<queue> #include<cstring> using namespace std; const int N=5000005; typedef long long ll; int read(){ char 阅读全文
posted @ 2021-08-28 20:38 dfydn 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 分层图最短路 #include<cstdio> #include<iostream> #include<cstring> #include<queue> using namespace std; const int N=50005; int n,m,k,tot; int head[N],dis[N] 阅读全文
posted @ 2021-05-30 20:45 dfydn 阅读(50) 评论(0) 推荐(0) 编辑
摘要: #include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<cstring> using namespace std; const int N=500005; typedef long long l 阅读全文
posted @ 2021-05-30 20:15 dfydn 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 只要保证图是联通的,并且最小边权尽可能大,所以用最大生成树来建图,在图上用lca求最小边权,对路径上的点不断取min #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> using namespace s 阅读全文
posted @ 2021-05-30 18:53 dfydn 阅读(72) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 29 下一页