#K15031. Compare Stamp Collections

    ID: 24266 Type: Default 1000ms 256MiB

Compare Stamp Collections

Compare Stamp Collections

Alice and Bob each have a collection of stamps. Each collection is represented as a list of integer values, where each value represents a stamp. Your task is to compare the two collections and determine the following:

  • The number of common stamps, i.e. \( |S_A \cap S_B| \).
  • The number of stamps unique to Alice's collection, i.e. \( |S_A \setminus S_B| \).
  • The number of stamps unique to Bob's collection, i.e. \( |S_B \setminus S_A| \).

Note that even if duplicate values appear in the input, each collection should be treated as a set of stamps.

inputFormat

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

  1. An integer \( n \) denoting the number of stamps in Alice's collection.
  2. A line with \( n \) space-separated integers representing Alice's stamps.
  3. An integer \( m \) denoting the number of stamps in Bob's collection.
  4. A line with \( m \) space-separated integers representing Bob's stamps.

outputFormat

Print three space-separated integers to standard output (stdout):

  • The count of common stamps.
  • The count of stamps unique to Alice's collection.
  • The count of stamps unique to Bob's collection.
## sample
5
1 2 3 4 5
5
4 5 6 7 8
2 3 3