Computer Science, asked by adnanhussain3768, 2 months ago

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 naikmichael1
33

Answer:

1 2

56

6 9

1 6

1 p ah

we it

ag ui

yu

Answered by arshaarunsl
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