【题解】洛谷P2661[NOIP2015]信息传递 并查集

题目链接 求最小环。可以通过并查集判断是否成环了。统计环长度可以再写一个无路径压缩的并查集,暴力的跳上去找。 #include<cstdio> #include<algorithm> using namespace std; const int N=2e5+10; inline int read() { int s=0,f=0;char ch=getchar(); while(ch<'0'||
相关文章
相关标签/搜索