Logo
(追記) (追記ここまで)

31298번 - Removing Vertices 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB32212066.667%

문제

You are given an bidirectional graph with $(n + 1)$ vertices numbered from 0ドル$ to $n$. There are no loops and no multiple edges in this graph. Additionally, all cycles pass through vertex 0. Your task is to remove the minimum possible number of vertices so that there are no cycles in the graph. You can not remove the vertex number 0.

입력

On the first line, there are two integers $n$ and $m$: the number of vertices excluding vertex 0ドル$ and the number of edges (1ドル \le n \le 10^5,ドル 1ドル \le m \le 10^6$).

Each of next $m$ lines contains two integers $a$ and $b$: the numbers of vertices connected by an edge (0ドル \le a, b \le n$).

It is guaranteered that all cycles pass through vertex 0ドル$.

출력

On the first line, print one integer $k$: the minimum possible number of vertices to remove. On the second line, print $k$ integers: the numbers of the vertices to remove in any order. If there are several optimal answers, print any one of them.

제한

예제 입력 1

4 6
0 1
1 2
2 0
0 3
3 4
4 0

예제 출력 1

2
1 3

예제 입력 2

3 5
0 1
1 2
2 0
2 3
3 0

예제 출력 2

1
2

힌트

출처

Contest > Open Cup > 2014/2015 Season > Stage 1: Grand Prix of SPb H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /