The contest scoreboard problem (uva 10258) is very straight forward programming challenge from competitive programming. Which can be stated as (from online judge)
Contestants are ranked first by the number of problems solved (the more the better), then by decreasing amounts of penalty time. If two or more contestants are tied in both problems solved and penalty time, they are displayed in order of increasing team numbers.
A problem is considered solved by a contestant if any of the submissions for that problem was judged correct. Penalty time is computed as the number of minutes it took for the first correct submission for a problem to be received plus 20 minutes for each incorrect submission received prior to the correct solution. Unsolved problems incur no time penalties.
This means that for every incorrect submission, contestant receive an penalty of 20 mins. Maximum number of problems solved by contestant in any submission is considered as final problems solved. Our task is to calculate the final score of contestant from his all submissions.
Given each input line consist four parts,
[contestant number] [number of problems solved] [time required] [submission status]
Each contestant will receive one of the five submission status ( ‘C’, ‘I’, ‘R’, ‘U’ or ‘E’. These stand for Correct, Incorrect, clarification Request, Unjudged and Erroneous submission), where submissions with 'R', 'U' and 'E' are ignored and not considered in final score.
For each incorrect submission, 20 mins are added to time slot as penalty, no incorrect submission is accepted after correct submission. While considering incorrect submission, time of that submission is skipped, instead +20 where added in place of it.
Explanation
we just have to check if submission is correct or not, if 'yes' then good, else add 20 mins in time slot for that contestant for every incorrect submission. Maintain flags to know that no incorrect submission should repeat after correct one.
Code
Board = {}
Final_score = {}
Teams = []
Useless = ['R','U','E']
temp = input().split(" ")
n = 0
Correct = dict()
Repeat = dict()
while(True): #Take input until user enters
try:
temp[1]
except:
break
Board[n] = temp
n = n+1
temp = input().split(" ")
for i in range(0,n):
for j in range(0,3):
Board[i][j] = int(Board[i][j]) #convert to int and add to repeat
Repeat[Board[i][0]] = False
Correct[Board[i][0]] = False
for i in range(0,n):
if(Board[i][3] in Useless):
continue
elif(Board[i][3] == 'I' and Correct[Board[i][0]] == False):
if(Repeat[Board[i][0]] == True):
Final_score[Board[i][0]][2] += 20
if(Board[i][1] > Final_score[Board[i][0]][1]):
Final_score[Board[i][0]][1] = Board[i][1]
else:
Repeat[Board[i][0]] = True
Board[i][2] = 20
Final_score[Board[i][0]] = Board[i]
elif(Board[i][3] == 'C'):
if(Repeat[Board[i][0]] == True):
Final_score[Board[i][0]][2] += Board[i][2]
if(Board[i][1] > Final_score[Board[i][0]][1]):
Final_score[Board[i][0]][1] = Board[i][1]
else:
Repeat[Board[i][0]] = True
Correct[Board[i][0]] = True #to avoid 'I' after 'C'
Final_score[Board[i][0]] = Board[i]
for i in Final_score:
print(str(Final_score[i][:3]))
After accepting input from user, we check if for any incorrect submission whether it is repeated or not. If yes then add 20 in Board[i][2] as time slot and add maximum number of problems solved in final_score (i.e by checking already exist solved number with new submission number, max is considered).
If repeated is false, then simply add 20 in time slot and add to final_score.
For every correct submission, if repeated is 'yes' then add time taken to solve problem with final score and number of problems solved as max number of problems solved in any submission.
If repeated is false, then marks correct flag as 1 to avoid incorrect submission after correct one, and add to final_score.
Related keywords: contest scoreboard, uva contest scoreboard problem, contest scoreboard online judge, contest scoreboard explanation, contest scoreboard source code, contest scoreboard solution python, uva 10258, uva 10258 solution, uva 10258 problem explanation.
Comments
Post a Comment