All submissions for this problem are available.
Zeus challenged his son Rubixius with a puzzle in which he presented a line of text which was modified on saying some magic words. Zeus asked him to keep track of the mutations and answer the current text in the string whenever asked.
Zeus wanted Rubixius to answer if any of these conditions held true. The conditions are prioritized with the first having highest priority.
1. Only answer if the string has changed.
2. To check if Rubixius was paying attention he had to answer the correct text after every K magic queries when Zeus did not ask him the answer.
3. Rubixius had to tell Zeus the last state of the string.
Rubixius mastered this game. Can you?
The first line will contain an integer T<50 with the number of Test Cases. Each case will start with a string S on a line. The following line contains 2 integers N and K where N is the number of queries and K is the query count after which Rubixius should automatically answer. Then N lines follow with 1 query/line.
|IZA i str||Insert string str at position i|
|DZA i j||Delete substring starting from i upto j|
|RZA i j str||Replace substring starting from i upto j with str|
|WZA i j k||Remove substring starting from i upto j and place it at k|
|KZA i j a b||Swap substring starting from i upto j with substring starting from a upto b|
A query starting with P means Zeus wants Rubixius to answer.
In the queries if j>string length, then take j to be the last index.
String length will always be less than 100.
String will be alphanumeric.
Output the text on a new line every time you need to.
Input: 1 stringmagiciseasy 6 2 IZA 13 not RZA 13 16 notvery PDZA 13 20 WZA 5 12 0 DZA 7 7 DZA 7 13 Output: stringmagicisnotveryeasy stringmagiciseasy magiciseasy
|Time Limit:||0.1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.