Programming contests

ECN programozó csapatverseny, 2018. május 12.

May 12, 2018 10:15 AM – May 12, 2018 3:15 PM

Information About Persons

The secret service of Landia decided to manage information about the whole people of Landia. Unfortunately, its computer scientists are completely helpless. The input looks as follows. The first line contains the number of records, n ≤ 200 000. On the next n lines, every record stores information about one person:

  • personal code (a 31-bit positive integer);
  • status (two to seven nonspace characters); the first character is always M or F (sex); if the second character is (minus), the person is dead; otherwise, if one of the next characters is C, the person is computer scientist; if one character is S, the person works for the secret service;
  • name of the person (8 to 35 characters, including space).

Why are the computer scientists of the secret service so helpless? The above list contains a lot of duplicates: every time a person changes its status or name, the new record is simply added at the end of the list.

The secret service wants to know:

  • how many men are living in Landia;
  • how many women are living in Landia;
  • how many computer scientists are working in Landia;
  • how many persons are working for the secret service;
  • the list of computer scientists who work for the secret service (in alphabetical order); display this list after one empty line.

Beware: consider only the last (actual) status of every person.

Sample Input

  1. 12
  2. 10 FAB Blue Mary
  3. 15 MCA Sonk Jean
  4. 10 FAS Rode Mary
  5. 20 FXS Aske Vera
  6. 20 F- Aske Vera
  7. 12 FDE Kant Mia
  8. 12 FSE Kant Mia
  9. 16 MUV Barbe Louis
  10. 21 MSC Conta Pietro
  11. 24 FCS Ando Maria
  12. 16 MCS Barbe Louis
  13. 25 FET Donk Laura
download as text file

Output for Sample Input

  1. 3 men
  2. 4 women
  3. 4 computer scientists
  4. 5 for secret service
  5. 24 FCS Ando Maria
  6. 16 MCS Barbe Louis
  7. 21 MSC Conta Pietro
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019