#K91042. Titanic Survivors Count

    ID: 37887 Type: Default 1000ms 256MiB

Titanic Survivors Count

Titanic Survivors Count

In this problem, you are given data about passengers on the Titanic. Each passenger record contains the passenger's name, age, class, and survival status. Your task is to count the number of survivors in each of the three classes. A passenger is considered a survivor if the 'Survived' field is 1.

Formally, let ( n ) be the number of passengers. For each passenger record, you are given:

  • A string ( Name )
  • An integer ( Age )
  • An integer ( Class ) (which can be 1, 2, or 3)
  • An integer ( Survived ) (either 0 or 1)

You must output three integers corresponding to the count of survivors in class 1, class 2, and class 3 respectively.

Example:

Input:
7
JohnDoe 25 1 1
JaneSmith 30 2 0
MaryJohnson 19 3 1
JamesBrown 40 1 0
EmilyDavis 22 2 1
MichaelWilson 50 3 0
ElizabethTaylor 29 1 1

Output:
2 1 1

inputFormat

The input is given via standard input (stdin). The first line is an integer ( n ) representing the number of passengers. The next ( n ) lines each contain a passenger's information in the following format:

Name Age Class Survived

Here:

  • Name: a string (without spaces) representing the passenger's name.
  • Age: an integer representing the passenger's age.
  • Class: an integer (1, 2, or 3) representing the ticket class.
  • Survived: an integer (0 or 1) indicating whether the passenger survived.

outputFormat

Output the number of survivors in class 1, class 2, and class 3 respectively, separated by a space. The output should be written to standard output (stdout).

sample

7
JohnDoe 25 1 1
JaneSmith 30 2 0
MaryJohnson 19 3 1
JamesBrown 40 1 0
EmilyDavis 22 2 1
MichaelWilson 50 3 0
ElizabethTaylor 29 1 1
2 1 1