摘要: 反向建图。 时间复杂度呢?(不会) #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) 编辑