};
sub calc_score{
- my ($user, $problem, $date, $tries) = @_;
+ my ($user, $problem, $date, $tries, $totaltime) = @_;
my $mxscore = LEVEL_VALUES->{problem_level($problem)};
my $score = $mxscore;
my $timetaken = $date - get_open($problem, $user);
- $timetaken = 1 if $timetaken < 1;
- $timetaken = 150 + int rand 150 if $timetaken > 3600;
- $score = (3600 - $timetaken) / 3600 * $score;
+ $timetaken = 0 if $timetaken < 0;
+ $timetaken = 300 if $timetaken > $totaltime;
+ $score = ($totaltime - $timetaken) / $totaltime * $score;
$score -= $tries / 10 * $mxscore;
$score = $mxscore * 3 / 10 if $score < $mxscore * 3 / 10;
int $score
sub _generate{
my ($self, $htc, $path, $lang) = @_;
+ my $totaltime;
$path =~ m,^(?:ct/([^/]+)/)?,;
- local $Gruntmaster::Data::contest = $1 if $1;
+ local $Gruntmaster::Data::contest;
+ if ($1) {
+ $totaltime = contest_end ($1) - contest_start ($1);
+ $Gruntmaster::Data::contest = $1;
+ }
my @problems = problems;
@problems = sort @problems;
for (1 .. jobcard) {
if ($Gruntmaster::Data::contest) {
$tries{job_user()}{job_problem()}++;
- $scores{job_user()}{job_problem()} = job_result() ? 0 : calc_score (job_user(), job_problem(), job_date(), $tries{job_user()}{job_problem()});
+ $scores{job_user()}{job_problem()} = job_result() ? 0 : calc_score (job_user(), job_problem(), job_date(), $tries{job_user()}{job_problem()}, $totaltime);
} else {
if (job_result_text =~ m/^(\d+)/) {
$scores{job_user()}{job_problem()} = $1;
user => $user,
score => sum (values $scores{$user}),
scores => [map { $scores{$user}{$_} // '-'} @problems],
+ problems => $Gruntmaster::Data::contest,
}
} keys %scores;
$htc->param(problems => [map { problem_name } @problems ]) if $Gruntmaster::Data::contest;