You have been given two strings, A and B (of length N each) and Q queries.
The strings contain only 0s and/or 1s.
For every query, you are given an index i. You have to update the value at index i to 1 in string B and check if B is lexicographically equal to or larger than A or not.
If yes, then print "\(YES\)" and if not, print "\(NO\)" (without quotes).
Input format
- First line contains two space-separated integers N and Q.
- Next line contains the string A.
- Next line contains the string B.
- Next Q lines contains an integer i (1 - based indexing)
Output Format
For each query, print the desired output in a new line.
Input Constraints
\(1 \le N\) , \(Q \le 10^6\)
\(1 \le i \le N\)
After 1st query: B = 10010. B < A. (NO)
After 2nd query: B = 11010. B < A. (NO)
After 3rd query: B = 11110. B < A. (NO)
After 4th query: B = 11110. B < A. (NO)
After 5th query: B = 11111. B = A. (YES)
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor