随笔分类 - 强联通分量
摘要:#include<queue> #include<cstdio> #include<cstring> #define N 500005 using namespace std; struct edge{ int to,val,next; } e[N]; int m,n,p,s,cnt,g[N],u[
阅读全文
摘要:#https://www.luogu.com.cn/problem/P1262 间谍网络 关键在缩点的时候选择性的tarjan 只会搜搜得到的点 #include <iostream> #include <cstring> #include <algorithm> #include <unorder
阅读全文
摘要:#https://www.luogu.com.cn/problem/P2194 对每个连通块的值求里面的点的最小值 然后加起来就是遍历所有点的最小值 方案数就根据乘法原理乘起来就可以 #include <iostream> #include <cstring> #include <algorithm
阅读全文
摘要:##https://www.luogu.com.cn/problem/P1407 给n个男 女关系 在给m个男 女关系 表示可能出轨的关系 如果原来的男女的关系断裂后(出轨) 是否能重新变成一个联通关系 这里使用强连通分量进行建图 对男设定为i 对应的女设为i+n 所以结果是i -> i+n #in
阅读全文
摘要:最长路 如果有正环就输出无解 a>b 那么b到a连一条长度为1的边 结论: 一个正环一定是某个scc中的 对于某个scc中的所有边 ,只要又一个边的权重是严格>0 因为u+w->b w>0 又u和v 在一个scc中 则v也一定能到v 所以就存在一个正环 那么当没有正环的时候 经过tarjan的图就是
阅读全文
摘要:第一问:给几个点传信息那么图的所有点都可以街道(看看起点p有几个点就可以了) 第二问:一个图变成强联通分量需要加几条边 结论 加max(p ,q )的边就可以 #include <iostream> #include <cstring> #include <algorithm> using name
阅读全文
摘要:#https://www.acwing.com/problem/content/1176/ 对于拓扑图 如果某一个点的出度为0 那么这个点就能被其他所有点到达 但是题目里所给的点不是拓扑图 所以我们需要缩点 强联通分量里面的所有点互相到达 外面的点到这个强联通的点可以到达 所以就可以强联通分量上的点
阅读全文