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

25446번 - Povjerenstvo 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB529927.273%

문제

Do you know how hard it is to choose a set of people for the problem selection committee? No? Well do you know who does? Mr. Malnar, of course. By observing human interactions, the all-knowing Mr. Malnar has decided what the ideal choice should look like.

A total of $N$ people are being considered for the committee and $M$ relations between them have been recorded. A relation is described by an ordered pair $(a, b)$ representing the fact that person $a$ dislikes person $b$. Mr. Malnar defines a dislike circle to be a sequence of distinct people $x_1, x_2, \dots , x_k$ such that person $x_i$ dislikes person $x_{i+1},ドル for each 1ドル ≤ i ≤ k$ (it is assumed that $x_{k+1} = x_1$). Mr. Malnar noticed a peculiar property regarding the set of people in question: there is no dislike circle consisting of an odd number of people.

To minimize dissatisfaction with the choice of committee, Mr. Malnar is looking for a committee such that everyone within the committee agrees with each other and everyone outside of the committee is glad not to be in it. More precisely:

  • There must not be two people within the committee such that one person dislikes the other.
  • For each person outside the committee there should be someone in the committee who they dislike.

Can you find such a set of people?

입력

The first line contains positive integers $N$ and $M,ドル the number of people and number of relations between them, respectively.

The $i$-th of the following $M$ lines contains an ordered pair of positive integers $a_i$ and $b_i$ (1ドル ≤ a_i , b_i ≤ N$), representing the fact that person $a_i$ dislikes the person $b_i$. It holds that $a_i ≠ b_i$ for all $i = 1, 2, \dots , M$ and no ordered pair is listed twice.

The given relations will be such that there is no dislike circle consisting of an odd number of people.

출력

If it is not possible to choose a set of people satisfying the given conditions, in the only line print -1.

Otherwise, in the first line print a positive integer $K$ (1ドル ≤ K ≤ N$), the number of people in the committee. In the next line print $K$ distinct positive integers $p_1, p_2, \dots , p_K$ (1ドル ≤ p_i ≤ N$), the indices of the people which make up the committee.

If there is more than one solution, output any one of them.

제한

In all subtasks, it holds that 1ドル ≤ N ≤ 500,000円$ and 0ドル ≤ M ≤ 500,000円$.

서브태스크

번호배점제한
113

There is no dislike circle.

221

There is no sequence of people of odd length $x_1, x_2, \dots , x_k$ such that one of $x_i$ or $x_{i+1}$ dislikes the other, for all 1ドル ≤ i ≤ k$.

333

$N, M ≤ 5000$

433

No additional constraints.

예제 입력 1

4 4
1 2
1 3
2 4
3 4

예제 출력 1

2
4 1

예제 입력 2

4 4
1 2
2 3
3 4
4 1

예제 출력 2

2
1 3

예제 입력 3

8 11
1 2
2 1
3 4
4 5
5 6
6 3
7 8
8 7
3 2
7 3
8 1

예제 출력 3

3
1 3 5

힌트

The set of chosen people is shown in the output of each test case.

The first example is a valid test case for the first subtask and for the second subtask.

The second example is not a valid test case for the first subtask, but it is valid for the second subtask.

The third example is not a valid test case for the first subtask nor for the second subtask.

출처

Olympiad > Croatian Highschool Competitions in Informatics > 2022 > Croatian Olympiad in Informatics 2022 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

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

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