Problem L
Deterministic Finite Automata - Maximum Word Length
You are given a deterministic finite automaton that accepts
the language
Input
The input contains the description of a deterministic finite automaton.
The first line contains four positive integers
Each state is an integer between
Output
Output the length of the longest word in
Sample Input 1 | Sample Output 1 |
---|---|
5 2 1 1 ab 3 2 3 3 4 4 5 5 4 4 4 |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
4 4 1 1 acgt 1 2 2 2 2 3 3 3 3 4 4 3 4 3 3 3 4 |
0 |