DAG - MarisaOJ: Marisa Online Judge

DAG

Time limit: 1000 ms
Memory limit: 256 MB
Given an directed graph without self-loop, determine whether this graph is a directed acyclic graph (DAG). ### Input - The first line contains two integers $n,m$. - The next $m$ lines, each line contains two integers $u, v$ an edge directed from $u$ to $v$. ### Output - Print `YES` if the given graph is an DAG, otherwise print `NO`. ### Constraints - $1 \le n,m \le 10^5$. - $1 \le u,v\le n$. ### Example Input: ``` 3 3 1 2 2 3 1 3 ``` Output: ``` YES ```