#C9907. Generating Unique Participant IDs
Generating Unique Participant IDs
Generating Unique Participant IDs
This problem requires you to generate unique participant IDs based on their last names and the order in which they appear. For each participant, you need to append the number of occurrences of that last name so far. For example, if the last name Lee
appears twice, then the first occurrence is assigned Lee1
and the second Lee2
.
More formally, if we denote by \( c(name) \) the count of occurrences of name up to the current position, then the unique ID for that participant is:
[ ID = \texttt{last_name} \Vert c(\texttt{last_name}), ]
where \(\Vert\) denotes string concatenation. Your solution should read from stdin
and output the result to stdout
.
inputFormat
The input is given via stdin
in the following format:
- The first line contains an integer
n
representing the number of participants. - If
n > 0
, the second line containsn
space-separated strings, each representing a last name.
outputFormat
Output a single line to stdout
containing the generated participant IDs, separated by spaces. If there are no participants (i.e., n = 0
), output an empty line.
4
Lee Wang Kim Lee
Lee1 Wang1 Kim1 Lee2
</p>