#C6988. Strongly Connected Graph
Strongly Connected Graph
Strongly Connected Graph
You are given a directed graph with \(n\) vertices and \(m\) edges. Your task is to determine whether the graph is strongly connected. A directed graph is strongly connected if there is a path from any vertex to every other vertex.
The input consists of the number of vertices \(n\) and the number of edges \(m\), followed by \(m\) directed edges. Each edge is represented by two integers \(u\) and \(v\) which indicate an edge from vertex \(u\) to vertex \(v\).
If the given graph is strongly connected, output Strongly Connected
; otherwise, output Not Strongly Connected
.
Note: For a graph with a single vertex and no edges, consider it strongly connected.
inputFormat
The first line contains two integers \(n\) and \(m\) separated by a space, where \(n\) is the number of vertices and \(m\) is the number of directed edges in the graph. The following \(m\) lines each contain two integers \(u\) and \(v\), representing a directed edge from vertex \(u\) to vertex \(v\). Vertices are numbered from 1 to \(n\).
outputFormat
Output a single line containing either Strongly Connected
if the graph is strongly connected; otherwise, output Not Strongly Connected
.
3 3
1 2
2 3
3 1
Strongly Connected
</p>