#C2897. Subsequence Construction Challenge

    ID: 46263 Type: Default 1000ms 256MiB

Subsequence Construction Challenge

Subsequence Construction Challenge

You are given a source string and a list of target strings. Your task is to determine, for each target string, whether it can be constructed from the source string by deleting zero or more characters without changing the order of the remaining characters.

Formally, a target string \( t \) is a subsequence of the source string \( s \) if there exists a sequence of indices \( 1 \leq i_1 < i_2 < \cdots < i_k \leq |s| \) such that \( s_{i_1} s_{i_2} \cdots s_{i_k} = t \). Use this idea to solve the problem.

Example:

Input:
abcde
4
ace
aec
abcd
xyz

Output: True False True False

</p>

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains the source string \( s \).
  • The second line contains a single integer \( n \) representing the number of target strings.
  • The following \( n \) lines each contain one target string \( t_i \).

outputFormat

For each target string, output on a new line "True" if it is a subsequence of the source string; otherwise, output "False". The results are printed to standard output (stdout).

## sample
abcde
4
ace
aec
abcd
xyz
True

False True False

</p>