10

Can anyone help me with a solution to this problem?

 2 years ago
source link: http://codeforces.com/blog/entry/101241
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Can anyone help me with a solution to this problem?
Two strings S and T each of length at most 10^5 consisting only of the lowercase English letters 'a' through 'r'. Given Q queries (1≤Q≤10^5). Each query provides a subset of the lowercase English letters from 'a' to 'r.' You need to determine for each query whether s and t, when restricted only to the letters in the query, are equal.

INPUT FORMAT: First line contains S. Second line contains T. Third line contains Q. Next Q lines each contain a query string. Within a query string, no letters are repeated. Furthermore, all query strings are in sorted order, and no query string appears more than once.

OUTPUT FORMAT : For each query, print 'Y' if S and T, when restricted only to the letters in the query, are equal, or 'N' otherwise.

SAMPLE INPUT: aabcd caabd 4 a ac abd abcd

SAMPLE OUTPUT: YNYN

//For the first query, both strings become "aa" when restricted only to 'a.' //For the second query, the first string becomes "aac" while the second string becomes "caa."


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK