Mock CCC '18 Contest 5 J5/S3 - Directed Graph Connectivity

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 0.6s
Memory limit: 1G

Problem type

Given a directed graph of N vertices and M edges, determine for each edge if it is possible to reach vertex N from vertex 1 given that that edge is deleted from the graph.

Constraints

1N50

1MN2N

1si,tiN,siti

Input Specification

The first line of the input contains two space-separated integers, N and M.

Each of the next M lines contains two space-separated integers, si and ti, indicating that the ith edge goes from vertex si to ti.

You may assume that any given tuple (si,ti) appears at most once.

Output Specification

Output M lines.

On the ith line, given that the ith edge is deleted, print YES if it is still possible to reach vertex N from vertex 1. Print NO otherwise.

Sample Input

Copy
3 3
1 2
2 1
2 3

Sample Output

Copy
NO
YES
NO

Comments

There are no comments at the moment.