#C14708. Array to Dictionary Mapping

    ID: 44387 Type: Default 1000ms 256MiB

Array to Dictionary Mapping

Array to Dictionary Mapping

You are given two JSON arrays: one representing a list of keys and the other representing a list of values. Your task is to create a dictionary (or map) that maps each key to its corresponding value.

Important Rules:
1. The keys array must contain only strings. If any key is not a string, output exactly "TypeError".
2. The two arrays must have the same length. If they do not, output exactly "ValueError".

The output should be a valid JSON object representing the mapping if the input is valid.

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  • The first line is a JSON array of keys (strings).
  • The second line is a JSON array of values (which may be integers, floats, or strings).

It is guaranteed that each array is non-empty (or empty properly) and the format follows valid JSON array notation.

outputFormat

If the input is valid, print to standard output (stdout) a JSON object that maps each key to its corresponding value.
If the lengths of the arrays do not match, print exactly "ValueError" (without quotes).
If any key is not a string, print exactly "TypeError" (without quotes).## sample

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