#CT00039. Nén xâu (Run-Length Encoding)
Nén xâu (Run-Length Encoding)
Run-Length Encoding
Version: Phuoc Hung OJ Extended
Problem Statement
You are given a string consisting only of uppercase Latin letters from A to Z.
Split into maximal consecutive runs of equal characters. Encode each run by writing its character followed immediately by the number of occurrences in that run. The count must always be written, even when it is .
Construct the encoded string.
Input
A single line containing .
Output
Print the encoded representation of .
Subtasks
- Subtask 1 (50 points): .
- Subtask 2 (50 points): .
- In every subtask, contains only
A..Z.
Examples
Input
AAABCCCCDDDA
Output
A3B1C4D3A1
Explanation
The runs are AAA, B, CCCC, DDD, and A, with lengths respectively. Therefore they are encoded as A3, B1, C4, D3, and A1, producing A3B1C4D3A1.
Liên quan
Trong các cuộc thi sau:
Phước Hưng - Kỳ Thi HSG Lớp 9 (Chuyên đề Xử Lý Chuỗi) - Đề Số 3