Processing math: 100%
Maximum path - MarisaOJ: Marisa Online Judge

Maximum path

Time limit: 1000 ms
Memory limit: 256 MB
Given an directed acyclic graph (DAG). Each vertex is assigned a lowercase letter. A path's value is the number of most frequently occuring letter. For example, marisa, the value should be 2 as letter a occurs 2 times. ### Input - The first line contains two integers n,m. - The second line contains a string. The ith character is the letter assigned to vertex i. - The next m lines, each line contains two integers u,v an edge directed from u to v. ### Output - Print the maximum value among all paths. ### Constraints - 1≤n,m≤105. - 1≤u,v≤n. ### Example Input: 54abaca12133445 Output: 3