report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Run-length encoding - MarisaOJ: Marisa Online Judge

Run-length encoding

Time limit: 1000 ms
Memory limit: 256 MB
Using the Run-Length Encoding string compression technique, we replace consecutive repeated characters with a single character followed by the count of its repetitions. For example, `aabbbbccccc` would be compressed to `2a4b5c`. Write a program to compress a string using Run-Length Encoding and to decode a compressed string. ### Input - The first line contains a string to be compressed. - The second line contains a string to be decoded. ### Output - The first line should print the compressed result of the input string. - The second line should print the decoded result of the input string. ### Constraints - Ensure that the length of the string to be compressed and the length of the string after decoding do not exceed $10^5$. The strings consist only of lowercase letters. ### Sample test ``` aabbbbccccc 1a1b1c ``` Output: ``` 2a4b5c abc ```
String
Length
Word Count
lowercase
Vowel
Digit sum
Strong password
Letter frequencies
Palindrome string
Palindrome substring
Caesar cipher
String occurences
Sum
String normalization
Run-length encoding
Expression
Topic
Basic
Rating 800
Solution (3) Solution