Dealing with duplicate records
There are
n
people in an old database. Engineers struggle to extract useful information from the dataset as some names collide. You are asked to help them so that they can work with that data. The database contains user names and their birth dates. There are many duplicate names and you are asked to de-duplicate them by adding a number next to them. If there are two people named Anna
, then the program should keep the first one and add a 1
to the second one. That will result in Anna
and Anna1
. If another Anna
is present in the database, the program should assign Anna2
to the name.The first line of the input contains a single integer
n
. The next n
lines contain space-separated names and birthdates.The program should print
n
lines, each with a unique name in the described format, and the corresponding birthdate.Input | Output |
5
Anna 08/08/1999
Bob 02/02/1998
Steven 09/02/2000
Anna 01/04/2004
Anna 01/04/2004 | Anna 08/08/1999
Bob 02/02/1998
Steven 09/02/2000
Anna1 01/04/2004
Anna2 01/04/2004 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB