随笔分类 - 图论-强连通分量
摘要:```cpp 【题目描述】: 在幻想乡,上白泽慧音是以知识渊博闻名的老师。春雪异变导致人间之里的很多道路都被大雪堵塞,使有的学生不能顺利地到达慧音所在的村庄。因此慧音决定换一个能够聚集最多人数的村庄作为新的教学地点。 人间之里由N个村庄(编号为1..N)和M条道路组成,道路分为两种一种为单向通行的,
阅读全文
摘要:题面:https://www.luogu.org/problemnew/show/P3627 cpp 本题可以将图中强连通分量缩点后再跑最长路即可。 Code: include include include define N 500005 using namespace std; struct e
阅读全文
摘要:```cpp 【题目描述】: 有向图强连通分量:在有向图G中,如果两个顶点vi,vj间(vi vj)有一条从vi到vj的有向路径,同时还有一条从vj到vi的有向路径,则称两个顶点强连通(strongly connected)。如果有向图G的每两个顶点都强连通,称G是一个强连通图。有向图的极大强连通子
阅读全文
摘要:题面:https://www.luogu.org/problemnew/show/P1407 cpp 本题建图时: 夫妻之间:女孩指向男孩 情人之间:男孩指向女孩 然后Tarjan求强连通分量,对于一对夫妻,如果两人在同一个强连通分量里,那么这对婚姻就是不安全的,反之,则是安全的。 Code: in
阅读全文
摘要:题面:https://www.luogu.org/problemnew/show/P2341
阅读全文
摘要:题面:https://www.luogu.org/problemnew/show/P2863 cpp 本题直接用tarjan求出图中节点数大于一的强联通分量个数,然后输出即可。 Code: include include include include include include include
阅读全文
摘要:```cpp include include include include include include include using namespace std; const int N=50005; int n,m,head[N],dfs[N],stack[N],low[N],cnt,t,to
阅读全文
摘要:```cpp include include include include include include include using namespace std; const int N=10005; int n,m,cnt,rcnt,head[N],rhead[N],t,rt,ans; boo
阅读全文

浙公网安备 33010602011771号