What Does UNIST Stand For?
Time limit1sMemory limit512 MB
Count ways to pick a prefix of each of N words so the concatenation spells UNIST, modulo 1e9+7.
- Level
Medium5 of 10
- Topics
- Dynamic programming, String, Hash map, Recursion
- Solved
- No attempts yet
Problem
UNIST stands for Ulsan National Institute of Science and Technology. One day, Woni wondered whether there are other words whose acronym is UNIST.
Let denote the length of a word . Given words , for each word , let be a string obtained by taking between 0 and characters from the front of . In other words, is a prefix of of length .
Find the number of ways to choose such that is UNIST. Here, the operation is string concatenation.
Input
The first line gives the number of words .
The next lines give the words , one per line.
Each is a string consisting of one or more uppercase English letters.
Output
Print the number of ways to choose such that is UNIST, modulo 1,000,000,007.