Problem K
Deterministic Finite Automata - Minimum 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 shortest word in
Sample Input 1 | Sample Output 1 |
---|---|
4 2 1 2 ab 2 4 2 3 3 2 3 3 1 2 |
1 |
Sample Input 2 | Sample Output 2 |
---|---|
4 4 1 2 acgt 1 2 2 2 2 2 3 3 3 3 4 4 3 4 3 3 3 4 |
0 |