tarjan演算法
//dfn為最先訪問的時間點
//low為本節點通過他的兒子更新到的最小時間點
stack<
int> s;
int vis[n]
,res;
vector<
int> a[n]
;void
dfs(
int x)
else
if(vis[y]==1
)//訪問過,但y在stack中
low[x]
=min
(low[x]
,low[y]);
}if(dfn[x]
==low[x]
)//強連通分量起點
vis[x]=0
; s.
pop();
}}intmain()
time=0;
res=0;
for(
int i=
1;i<=n;i++)if
(res==1)
printf
("yes\n");
else
printf
("no\n");
}return0;
}
HDU 1269 迷宮城堡 強連通分量
一道強連通分量的裸題,當只有乙個強連通分量的時候輸出yes,否則輸出no include include include include include include include include include include include using namespace std typed...
hdu 1269 迷宮城堡 強連通分量
problem 給乙個有向圖,問這個圖是否兩兩都可互相達。solution 求強連通分量,看一共有幾個強連通分量,如果只有乙個則兩兩可互相達。include include include include include include include include include include...
HDU1269迷宮城堡(強連通分量)
problem description 為了訓練小希的方向感,gardon建立了一座大城堡,裡面有n個房間 n 10000 和m條通道 m 100000 每個通道都是單向的,就是說若稱某通道連通了a房間和b房間,只說明可以通過這個通道由a房間到達b房間,但並不說明通過它可以由b房間到達a房間。gar...