CENCRY - Encryption

no tags 

Marko is going to write a secret letter to a friend. He thought it is better to encrypt letter so that no other person can read it. After long thought he came up with an encryption scheme which was lame but he thought it will work anyways.

To encrypt a text he first wrote two infinite strings of characters first string consists only of vowels and second string consists of consonants only.

aeiouaeiouaeiouaeiouaeiou....................
bcdfghjklmnpqrstvwxyzbcdfghjklmnpqrstvwxyz...
 
Following is the scheme for encryption :

  1. let c be any character to be encrypted.
  2. let k be the count of number of times c character occurred in text to be encrypted until now.
  3. first find which of two infinite string contains that character.
  4. then look for kth occurrence of that character in that string.
  5. replace character c by corresponding character in second string.

For example, encrypted text of "baax" will be "abho".

Input

First line of input will contains t, number of test cases. Then t test case follows each test case in a line. Each test case will be a string of small Latin alphabets. Length of string will be less than 5*10^4

Output

For each test case print encrypted text.

Sample :

Input:

2
baax
aaa

Output:

abho
bhn


hide comments
snk_255: 2023-06-08 07:51:35

Used python and got TLE even with O(n). After using os.read() to get all the inputs at once Accepted. Reading input was the bottleneck.

vengatesh15: 2017-01-23 15:51:40

AC in 1 go:-)

CoNtRaDiCtIoN: 2015-05-31 16:57:05

for those having wa test cases to ponder:
eeeeeeeeeee
cjpvbhntzgm
zzzzzzzzzzzz
aeiouaeiouae
vfghjklwerf
eouaeioicou

:.Mohib.:: 2015-05-24 06:17:40

Just love encryption..... :)

SHIVAM DIXIT: 2014-09-28 18:27:18

O(n) passes....easy peasy....if getting tle then, check ur solution for random inputs at http://www.spojtoolkit.com/

Last edit: 2014-09-28 18:27:44
Sahil Dua: 2014-09-27 22:53:12

My 100th :)

AC in C after 2-3 TLE in Python(for same logic)...

Aadithya U: 2014-04-08 20:21:09

tle for O(n).. ? Clue pls..

Rishav Goyal: 2013-12-23 10:46:14

ANy tricky testcase pleaase??

Himanshu: 2013-06-14 20:57:05

how to get rid of tle


Added by:Divyanshu Ranjan
Date:2010-10-27
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All