wordpress注册数学验证码,百度seo排名优化,学校网站前置审批,北京做网站建设有发展吗传送门 文章目录题意#xff1a;思路#xff1a;题意#xff1a; n≤2e5,m≤2e5n\le2e5,m\le2e5n≤2e5,m≤2e5。
思路#xff1a;
这是题是我上个题的一部分#xff0c;算是个小知识点#xff0c;暴力能过。 直接维护一个setsetset#xff0c;让后遍历所有点#xff…传送门
文章目录题意思路题意 n≤2e5,m≤2e5n\le2e5,m\le2e5n≤2e5,m≤2e5。
思路
这是题是我上个题的一部分算是个小知识点暴力能过。 直接维护一个setsetset让后遍历所有点如果当前这个点没有被遍历那么就放入队列中扩展出去每个点最多入队一次而且边数不会很多复杂度大约是(nm)logn(nm)logn(nm)logn
// Problem: E. Connected Components?
// Contest: Codeforces - Educational Codeforces Round 37 (Rated for Div. 2)
// URL: https://codeforces.com/problemset/problem/920/E
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)//#pragma GCC optimize(Ofast,no-stack-protector,unroll-loops,fast-math)
//#pragma GCC target(sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tunenative)
//#pragma GCC optimize(2)
#includecstdio
#includeiostream
#includestring
#includecstring
#includemap
#includecmath
#includecctype
#includevector
#includeset
#includequeue
#includealgorithm
#includesstream
#includectime
#includecstdlib
#define X first
#define Y second
#define L (u1)
#define R (u1|1)
#define pb push_back
#define mk make_pair
#define Mid (tr[u].ltr[u].r1)
#define Len(u) (tr[u].r-tr[u].l1)
#define random(a,b) ((a)rand()%((b)-(a)1))
#define db puts(---)
using namespace std;//void rd_cre() { freopen(d://dp//data.txt,w,stdout); srand(time(NULL)); }
//void rd_ac() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//AC.txt,w,stdout); }
//void rd_wa() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//WA.txt,w,stdout); }typedef long long LL;
typedef unsigned long long ULL;
typedef pairint,int PII;const int N1000010,mod1e97,INF0x3f3f3f3f;
const double eps1e-6;int n,m;
int p[N],se[N];
LL rest;
bool st[N];
setintv[N],all;
struct Node {int a,b,w,flag; bool operator (const Node W) const {return wW.w;}
}edge[N];int find(int x) {return xp[x]? x:p[x]find(p[x]);
}void get_block() {queueintq;vectorintnow;for(int i1;in;i) {if(!st[i]) {q.push(i); st[i]1;all.erase(i);while(q.size()) {int uq.front(); q.pop();now.clear();for(auto x:all) {if(v[u].count(x)) continue;q.push(x); now.pb(x);st[x]1;int afind(u),bfind(x);se[a]se[b];p[b]a;rest--;}for(auto x:now) all.erase(x);}}}
}int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);cinnm;rest1ll*n*(n-1)/2-m;for(int i1;in;i) all.insert(i),p[i]i;for(int i1;im;i) {int a,b; scanf(%d%d,a,b);v[a].insert(b); v[b].insert(a);}for(int i1;in;i) p[i]i,se[i]1;get_block();vectorintans;for(int i1;in;i) if(ifind(i)) ans.pb(se[i]);sort(ans.begin(),ans.end());printf(%d\n,ans.size());for(auto x:ans) printf(%d ,x);return 0;
}
/**/