Kernel Scheduler
시간 제한2초메모리 제한1024 MB
작업 의존 관계를 나타내는 방향 그래프에서 적어도 절반 이상의 간선을 남기면서 모든 사이클을 제거한다.
문제
You are developing the scheduling module for the new operating system. This module takes tasks to be executed and the dependencies between them and then puts them in a certain order for execution.
More formally, there are tasks numbered from to . You are also given dependencies numbered from to ; -th of them is described by two numbers --- and , meaning that the task should be executed before the task .
In some cases, there are cyclical dependencies --- situations when according to the dependencies given some task should be executed before , before , \ldots, and before and before . 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 original dependencies to preserve some of the original information. You are to write the program performing this task.
입력
- One line containing the numbers and (, ).
- further lines, each containing two numbers and (, ), describing the corresponding dependency between two tasks and .
출력
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 of the selected dependencies (please note that should be at least ) and the third line should contain numbers --- the ids of the selected dependencies. They are numbered from to in the order given in the input.