模板:
1 int vis[maxn],dfn[maxn],low[maxn]; 2 int n,m,a[maxn][maxn],lay; 3 #define mp make_pair 4 #define fi first 5 #define se second 6 vector<pair<int,int> >ans; 7 void tarjan(int u,int father) { 8 low[u]=dfn[u]=++lay; 9 vis[u]=1; 10 for(int v=0;v<n;v++) { 11 if(v==father) continue; 12 if(a[u][v]&&!vis[v]) { 13 tarjan(v,u); 14 low[u]=min(low[u],low[v]); 15 if(dfn[u]<low[v]) 16 ans.push_back(mp(min(u,v),max(u,v))); 17 } 18 else if(a[u][v]) low[u]=min(dfn[v],low[u]); 19 } 20 }