Bonus problem for 2018 Yang Final Exam
There was a lonely singer called Robert who ordered a beer and wanted to write a new song.
While he writes his song, he often changes the lyrics.
So he asks you to write a program for him.
There are 4 commands:
1. "w" : write the new line in the nth sentence.
2. "r" : print out all the lyrics in the newest version.
3. "a" : append the string after the nth sentence (if the nth sentence is blank, then create it.)
4. "s": swap two sentences
Hint:
The first line contains 1 number N, which means the number of instructions.
Each instruction will be one of the following:
It's guaranteed that
1. 0 <= x < 10000
2. the length of the "string" in each instruction < 50
3. the total length of each sentence might > 50, because of append
4. N <= 1,000,000
If there's a read instruction, output all the setence have so far.
if there's no any words in sentence , do not output anything , even a "\n".