#P8270. [USACO22OPEN] Subset Equality S
[USACO22OPEN] Subset Equality S
Problem Description
The cows are trying a new way to exchange coded information. They mix irrelevant letters into the relevant letters, making the message hard to decode.
The cows transmit two strings and . Each string has length at most and consists only of lowercase letters from 'a' to 'r'. To try to understand this coded message, you are given queries ().
Each query gives a subset of the lowercase letters from 'a' to 'r'. For each query, you need to determine whether and are equal when keeping only the letters given in the query.
Input Format
The first line contains .
The second line contains .
The third line contains .
The next lines each contain one query string. In a query string, all letters are distinct. Also, all query strings are already sorted, and no query string appears more than once.
Output Format
For each query, output 'Y' if and are equal when keeping only the letters given in the query; otherwise output 'N'.
aabcd
caabd
4
a
ac
abd
abcd
YNYN
Hint
[Sample Explanation]
For the first query, when keeping only the character 'a', both strings become "aa".
For the second query, the first string becomes "aac" while the second string becomes "caa".
[Testdata Properties]
- Test point 2 satisfies .
- Test points 3-11 have no additional constraints.
Translated by ChatGPT 5