#C1831. Coding Contest Leaderboard
Coding Contest Leaderboard
Coding Contest Leaderboard
In this problem, you are given data from a coding contest consisting of several rounds. In each round, a fixed number of problems are presented with associated positive scores. Each participant’s performance in a round is encoded as a binary string where '1' indicates that the problem was solved and '0' means it was not solved. The score a participant earns for a round is the sum of each problem's score if solved. You must calculate the total score for each participant across all rounds and then generate a leaderboard sorted by total score in descending order. In case of ties, the participant with the smaller number (1-indexed) comes first.
Input Format: The first line of input contains two integers N and R, where N is the number of participants, and R is the number of rounds. For each round, the input is structured as follows:
- A line containing an integer P, the number of problems in that round.
- A line containing P space-separated integers representing the score of each problem.
- N subsequent lines, each containing a binary string of length P. The i-th string represents the performance of the i-th participant in that round.
Output Format: For each participant (from the sorted leaderboard), output a line with two integers: the participant's number and their total score, separated by a space.
inputFormat
The input begins with a line containing two integers N (number of participants) and R (number of rounds). Then, for each round, there is:
- A line with an integer P, the number of problems in the round.
- A line with P space-separated integers representing the score for each problem.
- N lines each with a binary string of length P indicating whether a participant solved the corresponding problems ('1' for solved, '0' for not solved).
outputFormat
Output the leaderboard where each line contains two integers: the participant's number (1-indexed) and their total score, separated by a space. The leaderboard should be sorted by total score in descending order, and if scores are tied, by participant number in ascending order.## sample
2 2
3
4 2 3
101
011
2
1 5
01
11
1 12
2 11
</p>