
At the end of all M Participants completing the exam, the final correct answers get decided.
Based on these answers score of each candidate gets recalculated, and the one with the highest score is the TOPPER!!!
If more than one Participant gets the top score, then the one who attempted the exam first is treated as TOPPER.
The first line of the input contains a single integer ‘T’ representing the no. of test cases.
The first line of each test case contains two space-separated integers, ‘N’ and ‘M’, denoting the number of questions and number of participants, respectively.
The second line of each test case contains ‘N’ space-separated integers representing the default answers.
The following ‘M’ lines of each test case contain ‘N’ space-separated integers, denoting answers given by each participant.
For each test case, print two lines.
The first line for each test case contains ‘M’ space-separated integers representing the instant results of every participant.
The second line of each test case contains a single integer representing the TOPPER.
You are not required to print anything; it has already been taken care of. Just implement the function and return the answer in the form of an array of length ‘M’+1. The first ‘M’ integers represent instant results, and the last element denotes the TOPPER.
1 ≤ T ≤ 10
1 ≤ M, N ≤ 1000
0 ≤ responses and default answer ≤ 4
Time limit: 1 Sec
We just follow the instructions of the statement and for each participant, we first calculate the most frequent answer for that participant and then publish the instant results. After we have found instant results for each participant then we find out the topper which has the maximum number of correct answers as compared to the final frequent answers. Implementation details are as per the following algorithm.
Given Function