ENCONDIN - Run Length Encoding
Your task is to write a program that performs a simple form of run-length encoding, as described by the rules below.
Any sequence of between 2 to 9 identical characters is encoded by two characters.
The first character is the length of the sequence, represented by one of the characters
The second character is the value of the repeated character.
A sequence of more than 9 identical characters is dealt with by first encoding 9 characters, then the remaining ones.
Any sequence of characters that does not contain consecutive repetitions of any characters is represented by a
1 character followed by the sequence of characters, terminated with another
1 appears as part of the sequence, it is escaped with a
1, thus two
1 characters are output.
The input consists of letters (both upper- and lower-case), digits, spaces, and punctuation. Every line is terminated with a newline character and no other characters appear in the input.
Each line in the input is encoded separately as described above. The newline at the end of each line is not encoded, but is passed directly to the output.
Please remember if len=0 then print a blank line, It caused me 4WA and lot of time waste.
AC in 1 go
simple one read input as while(gets(str))
Don't use scanf to input the string as the input string can also contain spaces.
What is the maximum string length limit
more like precision...!!!
what is the answer for 11 ??
can somebody explain why is the output of
Last edit: 2013-10-17 17:24:42