A hackathon organizer assigns each of n registered participants to exactly one squad, identified by an integer squad id. Given the participant id and squad id for every registrant, report — for each participant, in the same order they were listed in the input — the total number of participants (including themselves) who share their squad id.
participantId squadId describing one participant. All participantId values are pairwise distinct.Print n lines. The i-th line must contain the i-th participant's participantId followed by a single space and the size of their squad (the count of participants, including themselves, who share that same squadId), listed in the same order the participants appeared in the input.
Example 1
Input
5 101 1 102 2 103 1 104 2 105 3
Expected
101 2 102 2 103 2 104 2 105 1
Explanation
Participants 101 and 103 are both in squad 1, so each reports squad size 2. Participants 102 and 104 are both in squad 2, so each reports size 2. Participant 105 is alone in squad 3, so it reports size 1.
Example 2
Input
1 42 100
Expected
42 1
Explanation
There is only one participant, so their squad (id 100) has exactly one member -- themself.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →