/**
[单连通] poj 2762
判断一个图是否是单连通的。
强连通缩点+拓扑排序,满足条件是拓扑排序后的序列相邻点间要有边,即存在有向边(topo[i],topo[i+1])。
*/
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
#define N 1024
vector<int> g[N];
int n,m,low[N],ord[N],id[N],sp,scnt,stk[N],tim;
int in[N],topo[N],tp;
vector<int> gg[N];
bool mat[N][N];
void dfs(int u)
{
int minc = low[u] = ord[u] = ++tim;
stk[sp++] = u;
for(int i = 0; i < g[u].size(); ++i){
int v = g[u][i];
if(ord[v] == 0)
dfs(v);
minc = min(minc,low[v]);
}
if(minc < low[u]){
low[u] = minc;
return ;
}
int t;
do{
id[t = stk[--sp] ] = scnt;
low[t] = n + 1;