【题解】CF 19E Fairy

题目描述
Once upon a time there lived a good fairy A. One day a fine young man B came to her and asked to predict his future. The fairy looked into her magic ball and said that soon the fine young man will meet the most beautiful princess ever and will marry her. Then she drew on a sheet of paper n n points and joined some of them with segments, each of the segments starts in some point and ends in some other point. Having drawn that picture, she asked the young man to erase one of the segments from the sheet. Then she tries to colour each point red or blue so, that there is no segment having points of the same colour as its ends. If she manages to do so, the prediction will come true. B wants to meet the most beautiful princess, that's why he asks you to help him. Find all the segments that will help him to meet the princess.

输入格式
The first input line contains two integer numbers: n n — amount of the drawn points and m m — amount of the drawn segments ( 1<=n<=10{4},0<=m<=10 1<=n<=10
4
,0<=m<=10
4
). The following m m lines contain the descriptions of the segments. Each description contains two different space-separated integer numbers v v , u u ( 1<=v<=n,1<=u<=n 1<=v<=n,1<=u<=n ) — indexes of the points, joined by this segment. No segment is met in the description twice.

输出格式
In the first line output number k k — amount of the segments in the answer. In the second line output k k space-separated numbers — indexes of these segments in ascending order. Each index should be output only once. Segments are numbered from 1 in the input order.

题意翻译
给出一张无向图,求删除一条边后此图变成二分图的所有删边种类。
输入输出样例
输入 #1
4 4
1 2
1 3
2 4
3 4
输出 #1
4
1 2 3 4
输入 #2
4 5
1 2
2 3
3 4
4 1
1 3
输出 #2
1
5

题目大意

给一张图,去掉一条边之后变成二分图。问有哪些边满足。
n,m <= 10 ^ 5

二分图<->无奇环
目标边是所有奇环的交集边
先随便求一棵生成树,树是二分图。如果一条非树边i-j,其中i,j的深度奇偶性一样,说明有奇环
分类
1.么有这种边
2.有1条这种边
去掉奇环上的任意一边
3.有多条这种边
每发现一个奇环,就给环上的边权值+1,目标边的权值是奇环的的数量
注意:目标边不能在偶环上

代码后续补。。。调了好久。。。
posted @ 2020-04-18 18:56  _Buffett  阅读(121)  评论(0编辑  收藏  举报