report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
DAG - FlandreOJ: Flandre 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 ```
DAG / Topological sort
DAG
Reading order
Longest path
Maximum path
Martian language
Edge direction
Train pass
Topic
Graph
Rating 1200
Solution (1) Solution