#K72997. Maximum Depth of a File System Tree
Maximum Depth of a File System Tree
Maximum Depth of a File System Tree
You are given a file system represented as a tree. The tree consists of n directories numbered from 1 to n with directory 1 being the root. The tree is described by m directed edges, where each edge is an ordered pair (u, v) indicating that directory u is the parent of directory v.
Your task is to determine the maximum depth of the file system tree. The depth of a tree is defined as the length of the longest path from the root directory to any leaf directory. Mathematically, if we denote the depth as \(d\), then for any node,
[ d = 1 + \max_{child}(d(child)) ]
If a node has no children, its depth is 1.
inputFormat
The input is read from stdin and has the following format:
- The first line contains two space-separated integers n and m, where n is the number of directories and m is the number of edges.
- The following m lines each contain two space-separated integers u and v representing a directed edge from directory u to directory v.
outputFormat
Output a single integer to stdout representing the maximum depth of the file system tree.
## sample1 0
1