WSCIPHER  Ws Cipher
Weird Wally's Wireless Widgets, Inc. manufactures an eclectic assortment of small, wireless, network capable devices, ranging from dog collars, to pencils, to fishing bobbers. All these devices have very small memories. Encryption algorithms like Rijndael, the candidate for the Advanced Encryption Standard (AES) are demonstrably secure but they don't fit in such a tiny memory. In order to provide some security for transmissions to and from the devices, WWWW uses the following algorithm, which you are to implement.
Encrypting a message requires three integer keys, k_{1}, k_{2}, and k_{3}. The letters [ai] form one group, [jr] a second group, and everything else ([sz] and underscore) the third group. Within each group the letters are rotated left by k_{i} positions in the message. Each group is rotated independently of the other two. Decrypting the message means doing a right rotation by k_{i} positions within each group.
Consider the message the_quick_brown_fox encrypted with k_{i} values of 2, 3 and 1. The encrypted string is _icuo_bfnwhoq_kxert. The figure below shows the decrypting right rotations for one character in each of the three character groups.
Looking at all the letters in the group [ai] we see {i,c,b,f,h,e} appear at positions {2,3,7,8,11,17} within the encrypted message. After a right rotation of k_{1}=2, these positions contain the letters {h,e,i,c,b,f}. The table below shows the intermediate strings that come from doing all the rotations in the first group, then all rotations in the second group, then all the rotations in the third group. Rotating letters in one group will not change any letters in any of the other groups.
[ai], k_{1}= 2  [jr], k_{2}= 3  [sz] and _, k_{3}= 1  

Encrypted:  _icuo_bfnwhoq_kxert  _heuo_icnwboq_kxfrt  _heuq_ickwbro_nxfot 
Decrypted:  _heuo_icnwboq_kxfrt  _heuq_ickwbro_nxfot  the_quick_brown_fox 
Changes:  ^^ ^^ ^ ^ 
^ ^ ^^ ^ ^ 
^ ^ ^ ^ ^ ^ ^ 
All input strings contain only lowercase letters and underscores(_). Each string will be at most 80 characters long. The k_{i} are all positive integers in the range 1100.
Input consists of information for one or more encrypted messages. Each problem begins with one line containing k_{1}, k_{2}, and k_{3} followed by a line containing the encrypted message. The end of the input is signalled by a line with all key values of 0.
For each encrypted message, the output is a single line containing the decrypted string.
Input: 2 3 1 _icuo_bfnwhoq_kxert 1 1 1 bcalmkyzx 3 7 4 wcb_mxfep_dorul_eov_qtkrhe_ozany_dgtoh_u_eji 2 4 3 cjvdksaltbmu 0 0 0
Output: the_quick_brown_fox abcklmxyz the_quick_brown_fox_jumped_over_the_lazy_dog ajsbktcludmv
hide comments
maximilian_21:
20160802 22:59:41
AC: in one go, interesting question


razor123:
20160627 13:32:36
There are few test cases where size of string exceeds 80 characters. Gave me wrong ans when I took MAX as 80 but when I increased it to 85 it got accepted. 

fasahat hussain:
20160617 23:17:43
nice implementing..


waelalgaml:
20160306 19:44:01
bla bla bla


Aswin Siva:
20160116 18:26:48
the_quick_brown_fox => _icuo_bfnwhoq_kxert  using (2, 3, 1) [ai] [jr] [sz _] 


(Tjandra Satria Gunawan)(æ›¾æ¯…æ˜†):
20150827 22:02:07
I'm sure this problem is easy, but SIGFPE is really unexpected :p 

anuveshkothari:
20150719 07:23:36
Last edit: 20150719 07:31:54 

Nitesh Tiwari:
20150614 21:15:48
Finally, after 3 SIGSEGV and 1 SIGFPE.


i_am_looser:
20150608 07:54:21
For me , it was easy to implement ;) Last edit: 20150608 07:54:56 

Shubham Mohanka:
20141016 13:19:54
can somebody give me a few corner cases

Added by:  Wanderley Guimarăes 
Date:  20060609 
Time limit:  0.194s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  ACM Mid Central Regionals 2001 