At a contest, a team (3 – 4 members) is given one computer and a set amount of time (typically 4 – 5 hours) to write programs which solve a set of problems (usually 5 – 7). Teams are then ranked by the number of problems they are able to successfully solve. If several teams solve the same number of problems, a team whose total time to solve those is less than that of another is ranked higher.
If team A solved 2 problems, the first being solved one hour into the contest, and the second 1-1/2 hours into the contest, their total time is 60 + 90 = 150 minutes. If a second team, B, solved their first problem in 45 minutes, and a second correct one after 2 hours, team B’s total time is 45 + 120 = 165 minutes. Thus A would be ranked above B
Those calculations imply that both teams had correct solutions on both of their problems the first time they submitted each solution. However, there is a time penalty of 20 minutes imposed on a team for each incorrect submission
they have had. The penalty is only imposed once the team has a correct submission for that particular problem
. Thus if, as above, team A had submitted two incorrect solutions to one of their problems that they ultimately got correct in 1 hour, the total time for that problem is 60 + 2(20) = 100
minutes. If that is the only change from above, team B would instead be ranked above team A since it had the lesser total time (165 minutes as opposed to 190 minutes). Penalty points are only added in after a team successfully solves that problem. If a team never has a correct solution to a given problem, but has 5 incorrect submissions, there is no penalty time added in for that problem
For this project, you are to determine the rankings for teams competing in a programming contest. Input will come from two files. The first,“ teams.txt” will contain a list of team names, one per line.
Although the [b]number of teams is not known, hardware limitations dictate that there can never be more than 20 teams allowed to participat
e. [/b] The second file, “submissions.txt” will be a list of all submissions, in chronological order, throughout the contest, one per line.
Each line will contain, in the given order:
The time of the submission (in hh:mm format)
The team name (a single word with no blanks)
The problem number (1-5)
The judged outcome of that submission – ‘C’ if correct, ‘I’ if incorrect
Thus, the line: 1:06 Coders 4 I indicates that team Coders submitted a solution to problem 4 and it was deemed an incorrect solution. The contest begins at noon (12:00).
Your program is to create a well-formatted table listing the teams in rank order and including the rank, the team name, the total number of problems solved, and the total time points assessed. Teams solving the same number of problems with the same number of total points should have the same rank.
This information should be written to the file results.txt.
if the contents of teams.txt is
and the contents of submissions.txt is
12:55 GroupA 3 C
1:18 Winners 3 I
1:23 Winners 3 C
2:24 Excellence 4 C
2:57 Undefeated 2 I
3:15 Winners 2 C
3:20 Coders 2 C
3:42 Undefeated 2 I
3:45 GroupA 4 C
3:55 GroupA 1 C
Then the contents of results.txt would be
RANK NAME SOLVED TIME
1 GroupA 3 515
2 Winners 2 298
3 Excellence 1 144
4 Coders 1 200
5 Undefeated 0 0
Here's my code so far. I'm trying to figure out my structs first.
using namespace std;
cout << "Rank" << ""<< "Name" <<""<< "Solved" <<""<< "Time" << endl;