#K72027. String Decomposition
String Decomposition
String Decomposition
Given a string containing only lowercase alphabets, decompose it into groups of consecutive identical characters. For each group, record its starting index and length. The output should be a JSON representation of a dictionary where each key is a character and its associated value is a list of segments formatted as [start, length].
For a group with starting index \(i\) and length \(l\), the segment is represented as \((i, l)\).
inputFormat
Input is read from standard input. It consists of a single line containing a string of lowercase letters (possibly empty).
outputFormat
Output to standard output a JSON string representing a dictionary. Each key in the dictionary is a character present in the input string, and its value is a list of segments, where each segment is represented as an array [start, length].## sample
aaaa
{"a":[[0,4]]}