#K12941. Categorize Books by Status

    ID: 23802 Type: Default 1000ms 256MiB

Categorize Books by Status

Categorize Books by Status

You are given two lists: one contains book titles and the other contains their corresponding statuses. Each status is either Available or Checked Out. Your task is to categorize the books into two groups based on their status. If the input lists are empty or their lengths do not match, output an empty JSON object {}.

The problem can be modeled as follows: given two sequences, T (book titles) and S (statuses), with the condition \[ |T| = |S| \] if not, the output should be empty. Otherwise, output a JSON dictionary with two keys: "Available" and "Checked Out", where each key maps to a list of titles corresponding to that status.

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains an integer n representing the number of books.
  • The next n lines each contain a book title (which may include spaces).
  • The following n lines each contain a status corresponding to the book title in the same order. A status is either Available or Checked Out.

If n is 0, the input will consist of a single line.

outputFormat

The output should be written to standard output (stdout) as a JSON object. The JSON object has two keys: "Available" and "Checked Out". Each key maps to an array of book titles having that status. If the input is empty or the lengths of the book titles and status lists do not match, output an empty JSON object: {}.

## sample
2
The Hobbit
War and Peace
Available
Checked Out
{"Available": ["The Hobbit"], "Checked Out": ["War and Peace"]}