Uva 12897 - Decoding Baby Boos

Sep 25, 2015

Author: Shahriar Manzoor
Alternate: Md. Towhidul Islam Talukder, Md Mahbubul Hasan
Type: Adhoc, string.
Solution: It is quite easy problem. It is already said whatever need to be done to solve this problem. However, if you have noticed the limit or the warning below the statement, you will understand that the naive solution will not work. But you need to notice that, the transformation only matters with the initial character, position of the character does not matter. So what you should do is to take initial string: “abc..z” and then apply the transformation in this 26 length string and then you will understand which character will be replaced by which character. (Collected from: http://www.bubt-cse.edu.bd/ACM-ICPC%202014%20Document/Final_problem_set_Analysis.pdf, 26/09/2015)

Describe: 
Let alp = {......,'A','B',........,'Z',..., '_'}

ASCII value of 'A' = 65
ASCII value of '_' = 95
alp [65] = 'A';
alp[95] = '_';

Given String: AABBCCY
if Rules are:
A B
B C
C A

1st: B replaces by A
alp = {......'A', 'A','C',...........}
2nd: C replaces by B
alp = {......'A', 'A','B',...........}
3rd: A replaces by C
alp = {......'C', 'C','B',...........}


Final: alp = {......'C', 'C','B',...........}

Output: CCCCCCY

Solved this problem within 0.009 s
Code in C( required time: 0.056 s) 


No comments:

Post a Comment