Given a directed graph with N nodes and Medges. Each node isassociated with lowercase english alphabet.Beauty of a path is defined as the number of most frequentlyoccurring alphabet.Find the most beautiful path and return the maximum beauty value ithas.
Answers
Answered by
33
Answer:
1 2
56
6 9
1 6
1 p ah
we it
ag ui
yu
Answered by
5
Input
The graph includes n nodes and m directed edges, as indicated by the first line, which has two positive values n, m (1 n, m 300 000).
A string s with just lowercase English letters appears on the second line. The letter allocated to the i-th node is the i-th character.
Then there are m lines. A directed edge from x to y is represented by the two integers x, y (1 x, y n) on each line. It's worth noting that x and y can be equal, and there can be numerous edges between them. It's also possible that the graph isn't connected.
Output
Produce a single line containing a single integer indicating the biggest value. Output -1 instead if the value can be arbitrarily huge.
#SPJ2
Similar questions
English,
1 month ago
Hindi,
1 month ago
Computer Science,
2 months ago
Math,
2 months ago
Math,
10 months ago
Computer Science,
10 months ago