#C13006. Character Positions Mapping

    ID: 42497 Type: Default 1000ms 256MiB

Character Positions Mapping

Character Positions Mapping

Given a string, convert all characters to lowercase and produce a dictionary that maps each unique character to a list of its 0-indexed positions in the string.

For example, for the input abca, the output should be {"a": [0, 3], "b": [1], "c": [2]}.

If the input is not a valid string, the program should raise an error. In this contest problem, the input is read from standard input and the output is printed to standard output as a JSON object.

inputFormat

A single line containing a string. The string may include letters, digits, spaces and other characters. The input is provided via standard input.

outputFormat

Print a JSON object representing a dictionary. The keys are the unique characters (in lowercase) from the input string, and the corresponding values are lists of 0-indexed positions where the character occurs. The output must be printed to standard output.## sample

abca
{"a":[0,3],"b":[1],"c":[2]}