Hacker
Time limit4sMemory limit512 MB
Simulate substring comparisons, substring copy from a fixed string, and range letter-increment operations on a mutable string of length N.
- Level
Hard9 of 10
- Topics
- Segment tree, Hash map, String matching, Linked list
- Solved
- No attempts yet
Problem
A hacker has broken into Miltos's e-mail account again. Miltos decides to replace his password with a much stronger one. The old password is a string of lowercase Latin letters, and the new password starts as an exact copy of . Miltos applies operations to the new password in order, and he asks you to simulate them.
There are three kinds of operations.
1 i j k: compare the substring of the new password from position to position with the substring of the new password that starts at position and has length . Print Y if the two substrings are equal, otherwise print N.2 i j k: replace positions to of the new password with the substring of the old password that starts at position and has length .3 i j: advance every letter of the new password from position to position to the next letter, cyclically. The letter a becomes b, b becomes c, and z becomes a.
Positions are counted from 1. Every operation is valid, so , and operations of kind 1 and kind 2 satisfy . The old password never changes, and the length of the new password is always .
Input
The first line contains the old password . The second line contains the number of operations . Each of the next lines contains one operation in one of the formats above.
Output
For every operation of kind 1, print Y or N on its own line, in the order the operations are given.