#C3422. Subsequence Matching
Subsequence Matching
Subsequence Matching
Given a string \(s\) and a list of words \(W\), your task is to determine how many words in \(W\) are subsequences of \(s\). A subsequence is a sequence that can be derived from \(s\) by deleting zero or more characters without changing the order of the remaining characters.
For example, if \(s = \texttt{abcde}\) and \(W = [\texttt{a}, \texttt{bb}, \texttt{acd}, \texttt{ace}]\), then the count of matching subsequences is 3 because "a", "acd", and "ace" are valid subsequences, while "bb" is not.
The problem requires you to read input from standard input (stdin) and print output to standard output (stdout).
inputFormat
The input is read from stdin and has the following format:
- The first line contains the string \(s\).
- The second line contains an integer \(n\), the number of words.
- The next \(n\) lines each contain a word.
outputFormat
Output a single integer to stdout representing the count of words that are subsequences of \(s\).
## sampleabcde
4
a
bb
acd
ace
3