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

30568번 - Kernel Scheduler 스페셜 저지다국어

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

문제

You are developing the scheduling module for the new operating system. This module takes $n$ tasks to be executed and the dependencies between them and then puts them in a certain order for execution.

More formally, there are $n$ tasks numbered from 1ドル$ to $n$. You are also given $m$ dependencies numbered from 1ドル$ to $m$; $i$-th of them is described by two numbers --- $a_i$ and $b_i,ドル meaning that the task $a_i$ should be executed before the task $b_i$.

In some cases, there are cyclical dependencies --- situations when according to the dependencies given some task $t_1$ should be executed before $t_2,ドル $t_2$ before $t_3,ドル \ldots, and $t_{k-1}$ before $t_k$ and $t_k$ before $t_1$. Cyclical dependencies create a problem for scheduling, so you decided to remove some of the given dependencies in such a way that the resulting set does not contain any cyclical ones.

However, you still need to keep at least $m/2$ original dependencies to preserve some of the original information. You are to write the program performing this task.

입력

  • One line containing the numbers $n$ and $m$ (2ドル \le n \le 10^5,ドル 1ドル \le m \le 3 \cdot 10^5$).
  • $m$ further lines, each containing two numbers $a_i$ and $b_i$ (1ドル \le a_i, b_i \le n,ドル $a_i \ne b_i$), describing the corresponding dependency between two tasks $a_i$ and $b_i$.

출력

The first line should should contain YES in case the desired subset of dependencies exists, and NO otherwise.

In the YES case second line should contain the number $k$ of the selected dependencies (please note that $k$ should be at least $m/2$) and the third line should contain $k$ numbers --- the ids of the selected dependencies. They are numbered from 1ドル$ to $m$ in the order given in the input.

제한

예제 입력 1

3 3
1 2
2 3
3 1

예제 출력 1

YES
2
1 2

예제 입력 2

2 5
1 2
1 2
1 2
2 1
2 1

예제 출력 2

YES
3
1 2 3

예제 입력 3

4 4
1 2
2 3
2 4
3 4

예제 출력 3

YES
4
1 2 3 4

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > The UK & Ireland Programming Contest > UKIEPC 2023 K번

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

출처

대학교 대회

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

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