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

17511번 - Capital 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB20412511267.470%

문제

You are given $N$ cities connected by $M$ roads. Cities are numbered from 1 through $N,ドル and roads are numbered from 1 through $M$. For each pair of cities, there is a sequence of roads that connects those two cities. Road $i$ has the length $L_i$ kilometre and connects city $A_i$ and city $B_i$ bidirectionally. Every road has a positive length, so $L_i > 0$. Unfortunately, you have forgotten the length of each road.

You observed that, for each road, all people on road $i$ are going from $A_i$ to $B_i,ドル in a single direction. So, you assumed the hypothesis as follows:

  • There is a capital city called $S$.
  • People are moving from the capital city to other cities.
  • People try to move in the shortest path. So the length of the shortest path from $S$ to $A_i$ is less than or equal to the length of the shortest path from $S$ to $B_i$.

Can you find the capital city $S$ which meets the criteria when you can assign the length of each road to be any positive real number? You may assume that there is at least one city that meets the criteria.

입력

The first line of the input contains two integers $N$ (2ドル \le N \le 500$) and $M$ ($N-1 \le M \le \frac{N(N-1)}{2}$).

In the $i$-th line of next $M$ lines, $A_i$ and $B_i$ are given. (1ドル \le A_i,\ B_i \le N$)

There are no loops or multiple edges. Formally, $A_i \ne B_i,ドル and $\{A_i,\ B_i\} = \{A_j,\ B_j\} \implies i = j$.

출력

In the first line, print the number of possible capital cities, $K$.

In the second line, print $K$ space-separated integers which denotes all possible cities for the capital, in increasing order.

제한

예제 입력 1

2 1
1 2

예제 출력 1

1
1

힌트

출처

University > KAIST > KAIST ICPC Mock Competition > 2019 KAIST 9th ICPC Mock Competition D번

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

출처

대학교 대회

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

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