#P9114. [IOI 2009] POI
[IOI 2009] POI
Background
IOI 2009 D1T3.
Problem Description
The Plovdiv Olympiad in Informatics (POI) is being held. There are contestants and tasks. Each task has only one set of testdata, so for each contestant and each task, either the contestant solved the task or did not solve it. There is no partial score.
After the contest ends, the score of each task equals the number of contestants who did not solve that task. Each contestant’s total score is the sum of the scores of all tasks they solved.
Philip took part in the contest, but he was confused by the complicated scoring rules. Looking at the results, he cannot compute his final rank. Write a program to help Philip compute his score and rank.
Before the contest starts, each contestant is numbered from to . Philip’s number is . The final scoreboard lists all contestants in decreasing order of score. To avoid ties, among contestants with the same score, they are sorted by decreasing number of solved tasks (a contestant who solved more tasks is ranked before one who solved fewer). If there is still a tie, they are sorted by increasing contestant number.
Task: Given each contestant’s solving status, compute Philip’s score and his rank on the final scoreboard.
Input Format
The first line contains three integers , separated by single spaces, representing the number of contestants, the number of tasks, and Philip’s number.
The next lines describe each contestant’s solving status. Line describes contestant number and contains integers or , separated by spaces. The -th number indicates whether contestant number solved task () or not ().
Output Format
Output one line with two integers separated by a space: Philip’s score in POI and his rank on the final scoreboard. The rank is an integer in , where means the contestant is at the top of the scoreboard and means the contestant is at the bottom.
5 3 2
0 0 1
1 1 0
1 0 0
1 1 0
1 1 0
3 2
Hint
Sample Explanation
Only one contestant did not solve the first task, so it is worth point. Two contestants did not solve the second task, so it is worth points. Four contestants did not solve the third task, so it is worth points. Therefore, contestant number scores points, contestants number score points, and contestant number scores point. According to the tie-breaking rules, contestant number (Philip) is ranked before contestants number , so Philip’s final rank is , just below contestant number .
Constraints and Notes
- For of the testdata, no contestant has the same score as Philip.
- For of the testdata, , .
Translated by ChatGPT 5