Shifu and Strings
All submissions for this problem are available.
Master Shifu has to teach Po - the chosen dragon warrior, the art of Kung Fu. Po is very irritating, and Master Shifu does not want to teach him, but he has to, because Grand Master Oogway, Master Shifu's mentor, has told him to. So Shifu decides to give Panda a difficult task so that Shifu can rest while he is busy with the task.
Master Shifu gives Po a string of length N, consisting of all lowercase characters from 'a' to 'z'. Then Shifu gives Po Q queries, and in each query consisting of three integers L, R and K. In each query, Po is expected to increase the character in the string from index L to R(inclusive) by K.
For example, if K = 7 and the character is 'c', then Po needs to convert this character to 'c' + 7 = 'j'.
Also, in case if the new character exceeds 'z', Po needs to start adding from again from 'a'. For example, if K = 7 and the character is 'x', then first Po will add 2 to make it 'z', then the next time he adds, it will become an 'a'. So finally 'x' + 7 = 'e'.
To make it more difficult, Shifu can give the value of K to be negative as well. In this case, Po needs to subtract from each character. For example, if the character is 'e' and K = -7, the final character will be 'x'.
Master Shifu has asked Po to produce the final string after processing all the queries. But Po is very lazy. Like you read this question till here, Po did not even bother to read the question, and went to sleep. Now the world is in your hands, and you need to solve this puzzle for Po.
First line of input contains an integer T, the number of test cases.
First line of each test case will contain two integers N and Q, the length of the string and the number of queries.
The second line of each test case contains the string S on which you need to work.
The following Q lines contain three integers each, L, R and K.
For each test case, output a single line containing the final string after processing all the queries.
- 1 ≤ T ≤ 100
- 1 ≤ N,Q ≤ 5000
- 1 ≤ L ≤ R ≤ N
- -1000 ≤ K ≤ 1000
- |S| = N
Input: 2 4 3 abcd 1 4 1 3 4 2 2 3 3 8 4 abcdhgfe 1 5 2 2 6 3 3 7 -5 4 8 -6 Output: bfig cgcxbyuy
|Tags||ad-hoc, dmnt2016, easy-medium, sahilarora.535|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, 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, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions