#K36887. Parking Lot Available Spots

    ID: 25854 Type: Default 1000ms 256MiB

Parking Lot Available Spots

Parking Lot Available Spots

You are given a string representing a parking lot. Each parked car is represented by a three‐character segment, where the first character is an uppercase Latin letter denoting the level and the next two characters are digits representing the spot number. The parking lot has 99 spots per level. Your task is to determine the number of available spots on each level.

The rules are as follows:

  1. If the input string is empty, output an empty list: [].
  2. The string length must be a multiple of 3. Otherwise, output [-1].
  3. If any car (i.e. any three‐character segment) appears more than once, output [-1].
  4. For each level, if the number of parked cars exceeds 99, output [-1].

If the input is valid, for every level (sorted in alphabetical order), output a tuple in the form (level, available_spots), where available_spots is calculated by (99 - (\text{number of parked cars on that level})). The final output should be printed as a list.

For example, given the input A01B02A03C01B04, the output should be [('A', 97), ('B', 97), ('C', 98)].

inputFormat

Input is provided via standard input (stdin) as a single line string. The string may be empty. Each valid car entry in the string is exactly three characters long.

outputFormat

Output the result to standard output (stdout). The output is either a list of tuples in the format [(level, available_spots), ...] for a valid input or [-1] if the input is invalid.## sample

A01B02A03C01B04
[('A', 97), ('B', 97), ('C', 98)]