EASYPIE - Easy Problem

no tags 

Last year there were a lot of complaints concerning the set of problems. Most contestants considered our problems to be too hard to solve. One reason for this is that the team members responsible for the problems are not able to evaluate properly whether a particular problem is easy or hard to solve. (We have created until now so many problems, that all seems quite easy.) Because we want our future contests to be better we would like to be able to evaluate the hardness of our problems after the contest using a history of submissions.

There are a few statistics that we can use for evaluating the hardness of a particular problem: the number of accepted solutions of the problem, the average number of submissions of the problem and the average time consumed to solve it (as "General rules" of the contest state "the time consumed for a solved problem is the time elapsed from the beginning of the contest to the submittal of the accepted run"). For the latter two statistics we consider only the teams which solved this particular problem. Needless to say we ask you to write a program that computes aforementioned statistics for all problems.

Task

Write a program that:

  • reads a history of submissions during an ACM contest,
  • computes for each problem the number of accepted solutions of the problem, the average number of submissions and the average time consumed to solve it,
  • writes the result.

Input

The input begins with the integer t, the number of test cases. Then t test cases follow.

For each test case, the first line of the input contains one integer n (1 <= n <= 2000) being the number of submissions during the contest. Each of the next n lines describes one submission and contains a submission time (measured in seconds from the beginning of the contest), a team identifier, a problem identifier and a result of evaluating the submission separated by single spaces. The submission time is a positive integer not greater then 18000. The team identifier is a non-empty string consisting of at most five small letters or digits. The problem identifier is a capital letter A, B ... or I. The result is a capital letter A (the submission is accepted) or R (the submission is rejected).

Submissions are given in nondecreasing order according to submission times and there are 62 teams competing.

Please note that if a problem is accepted all further submission of this problem by the same team are possible but they should not be taken to the statistics.

Output

For each test case the output consists of nine lines. The first line corresponds to problem A, the second line to problem B, and so on. Each line should contain the problem identifier, the number of accepted solutions of the problem, the average number of submissions done by teams that solved that problem and the average time consumed to solve it separated by single spaces. The latter two statistics should be printed only if there was at least one accepted solution of the given problem and should be rounded to two fractional digits (in particular 1.235 should be rounded to 1.24).

Example

Sample input:
1
12 
10 wawu1 B R 
100 chau1 A A 
2000 uwr2 B A 
2010 wawu1 A R 
2020 wawu1 A A 
2020 wawu1 B A 
4000 wawu2 C R 
6000 chau1 A R 
7000 chau1 A A 
8000 pp1 A A 
8000 zil2 B R 
9000 zil2 B A 

Sample output:
A 3 1.33 3373.33 
B 3 1.67 4340.00 
C 0 
D 0 
E 0 
F 0 
G 0 
H 0 
I 0 

hide comments
Vivek Mangal: 2016-02-04 20:15:56

why my code is showing WA?(id=16230381)

lordroxton: 2010-04-17 10:54:26

@Muhamed Buvanov
Total time is (for problem A): (100 + 2020 + 8000) = 10120
10120 / 3 = 3373.33(3)
Keyword: "first accepted submissions".

Mukhamed BUVANOV: 2010-03-19 09:08:37

For the problem A the total time is
(100+2010+2020+8000)=12130
and if we take it's average (12130/4)=3032.50 instead of 3373.33 why?

Last edit: 2010-03-19 09:09:00
Luka Hrabar: 2010-01-06 15:55:52

number of submissions - N
100 chau1 A A -> N++
2010 wawu1 A R -> N++
2020 wawu1 A A -> N++
6000 chau1 A R -> they already solved it so we don't count this submission
7000 chau1 A A -> they already solved it so we don't count this submission
8000 pp1 A A -> N++

N=4, average is 4 / 3 = 1.33
Repeat the same process for the average time consumed but only sum the times of their first accepted submissions.

Last edit: 2010-01-06 17:22:48
Seshadri R: 2009-12-23 09:39:13

100 chau1 A A
6000 chau1 A R
7000 chau1 A A
chau1's first submission is accepted. Next time it was rejected. Third time, it is accepted. What is the total number of submission for problem A and how to arrive at 1.33 and 3373.33?


Added by:adrian
Date:2004-06-26
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS PERL6 VB.NET
Resource:ACM Central European Programming Contest, Warsaw 2003