题意:在一张图中,让你求割边。并按照顺序数出来,注意图并不是连通的。
思路:对多个连通分支,每个执行一次dfs求割边。最后排序输出就好了。
代码如下:
1 #include2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #define MP(a, b) make_pair(a, b)11 #define PB(a) push_back(a)12 13 using namespace std;14 15 typedef long long ll;16 typedef pair pii;17 typedef pair puu;18 typedef pair pid;19 typedef pair pli;20 21 const int INF = 0x3f3f3f3f;22 const double eps = 1e-6;23 const int LEN = 1010;24 struct Arc{25 int from, to;26 }bri[LEN];27 int mp[LEN][LEN], n, nbri, low[LEN], dfn[LEN], dfs_clock, vis[LEN];28 vector Map[LEN];29 inline bool cmp(Arc a, Arc b)30 {31 if(a.from != b.from) return a.from dfn[u])bri[nbri].from = min(u, v), bri[nbri++].to = max(v, u);53 }54 }55 }56 57 int main()58 {59 // freopen("in.txt", "r", stdin);60 61 int from, to, tn;62 while(scanf("%d", &n)!=EOF)63 {64 memset(mp, 0 ,sizeof mp);65 for(int i=0; i