#C1432. Opposite Substring Verification
Opposite Substring Verification
Opposite Substring Verification
Given two strings \(S\) and \(T\) each of length \(n\) and \(q\) queries, determine for each query whether the specified substrings of \(S\) and \(T\) are opposites. Two substrings \(S[i:j]\) and \(T[i:j]\) (with indices being 1-indexed) are defined as opposites if they are anagrams; that is, they contain the same characters with the same frequencies. Formally, the substrings are opposites if \(\text{Counter}(S[i:j]) = \text{Counter}(T[i:j])\).
inputFormat
The input is provided via standard input and follows the format below:
- The first line contains an integer \(n\) representing the length of the strings.
- The second line contains the string \(S\).
- The third line contains the string \(T\).
- The fourth line contains an integer \(q\), the number of queries.
- Each of the following \(q\) lines contains two space-separated integers \(i\) and \(j\) (1-indexed) denoting the starting and ending indices of the substrings to be compared.
outputFormat
For each query, output a single line containing either "Yes" if the two substrings are opposites (i.e. anagrams), or "No" if they are not.
## sample4
abcd
dcba
2
1 4
1 2
Yes
No
</p>