Being tired of the challenging assignments given by the MCS Professors, students have collectively decided to have a roasting contest with the professors. We divide participants into two teams: students and professors. Each participant gets 500 points for their team when they roast a participant from the opposing team. Moreover, if the same participant roasts someone from the opposing team again within 10 minutes, their team gets an additional 500 points. For example, if a participant roasts twice within 10 minutes, their team gets 500+500 = 1000 points. As another example, if a participant roasts for the first time, roasts for the second time within 10 minutes, and then roasts within 10 minutes of their second roast, their team gets 500 + (500 + 500) + (500 + 500) = 2500 points. Input The first line contains the integer n (1 <= n <= 200), the number of times participants roasted each other in the contest. The second line contains the integer m1 denoting the total number of students. The third line contains the integer m2 denoting the total number of professors. Each of the following n lines contains one of the following: t_i sj pk t_i pk sj In the lines above, 0 <= t_i <= 120, 1 <= j <= m1, 1 <= k <= m2 denoting student sj, professor pk, and time t_i (in minutes). Note here that while j and k are integers, s and p are characters denoting “student” and “professor” respectively. The line t_i sj pk denotes that student j roasted professor k at time t_i, while t_i pk sj denotes that professor k roasted student j at time t_i. The numbers t_i are distinct and are in increasing order. Output One line with the total score of team students, a space, and the total score of team professors. Sample Input 1 3 3 3 1 s1 p2 2 s1 p1 3 p1 s2 Sample Output 1 1500 500
code in python
Being tired of the challenging assignments given by the MCS Professors, students have collectively decided to have a roasting contest with the professors. We divide participants into two teams: students and professors. Each participant gets 500 points for their team when they roast a participant from the opposing team. Moreover, if the same participant roasts someone from the opposing team again within 10 minutes, their team gets an additional 500 points.
For example, if a participant roasts twice within 10 minutes, their team gets 500+500 = 1000 points.
As another example, if a participant roasts for the first time, roasts for the second time within 10 minutes, and then roasts within 10 minutes of their second roast, their team gets 500 + (500 + 500) + (500 + 500) = 2500 points.
Input
- The first line contains the integer n (1 <= n <= 200), the number of times participants roasted each other in the contest.
- The second line contains the integer m1 denoting the total number of students.
- The third line contains the integer m2 denoting the total number of professors.
- Each of the following n lines contains one of the following:
- t_i sj pk
- t_i pk sj
- In the lines above, 0 <= t_i <= 120, 1 <= j <= m1, 1 <= k <= m2 denoting student sj, professor pk, and time t_i (in minutes). Note here that while j and k are integers, s and p are characters denoting “student” and “professor” respectively. The line t_i sj pk denotes that student j roasted professor k at time t_i, while t_i pk sj denotes that professor k roasted student j at time t_i.
- The numbers t_i are distinct and are in increasing order.
Output
One line with the total score of team students, a space, and the total score of team professors.
Sample Input 1
3
3
3
1 s1 p2
2 s1 p1
3 p1 s2
Sample Output 1
1500 500
Sample Input 2
4
4
5
1 s1 p1
3 p1 s2
4 s2 p2
5 p4 s1
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images