#C8252. Most Played Songs and Artists
Most Played Songs and Artists
Most Played Songs and Artists
In this problem, each user has a listening history represented by a series of records. Each record consists of three integers: a user identifier, a song identifier, and an artist identifier. Your task is to identify, for each user, the song and the artist that appears most frequently in their history. In the case of a tie (i.e. multiple songs or artists having the same highest frequency), choose the smallest identifier.
For a user ( u ), let the frequency of a song ( s ) be defined as the number of times ( s ) appears in the listening history of ( u ). Formally, if ( f(u, s) ) denotes this frequency, you should choose the song ( s ) such that ( f(u, s) ) is maximized, and if there exists another song with the same frequency, select the one with the smallest numerical value. The same rule applies for selecting an artist.
inputFormat
The input is read from stdin. The first line contains an integer (n) representing the number of records. This is followed by (n) lines, each containing three space-separated integers: the user identifier, the song identifier, and the artist identifier.
outputFormat
For each unique user (sorted in increasing order), output a line with three space-separated integers: the user identifier, the most played song identifier, and the most played artist identifier.## sample
1
1 100 10
1 100 10
</p>