Example #1
0
function gen_new_problem($arg_min, $arg_max, $oper, $doubles = false, $nf = true, $word = false)
{
    if ($word) {
        $_SESSION['wordproblem'] = true;
    } else {
        if (isset($_SESSION['wordproblem'])) {
            unset($_SESSION['wordproblem']);
        }
    }
    $argument1 = get_new_number($arg_min, $arg_max);
    if (!$doubles) {
        $argument2 = get_new_number($arg_min, $arg_max);
    } else {
        $argument2 = $argument1;
    }
    #echo $argument1.' '.$argument2."\n";
    while (!check_problem($argument1, $oper, $argument2, $arg_min, $arg_max)) {
        $argument1 = get_new_number($arg_min, $arg_max);
        if (!$doubles) {
            $argument2 = get_new_number($arg_min, $arg_max);
        } else {
            $argument2 = $argument1;
        }
    }
    if (!$word) {
        display_math_problem($argument1, $oper, $argument2, $nf);
    } else {
        display_word_problem($argument1, $oper, $argument2, $nf);
    }
}
Example #2
0
        }
    } else {
        $detail .= "OK";
    }
    $detail .= "\n";
}
result('contests', 'Contests integrity', $has_errors ? 'E' : 'O', $detail);
flushresults();
// PROBLEMS
$res = $DB->q('SELECT probid, cid, shortname, timelimit, special_compare, special_run
               FROM problem INNER JOIN contestproblem USING (probid)
               ORDER BY probid');
$details = '';
while ($row = $res->next()) {
    $CHECKER_ERRORS = array();
    check_problem($row);
    if (count($CHECKER_ERRORS) > 0) {
        foreach ($CHECKER_ERRORS as $chk_err) {
            $details .= 'p' . $row['probid'] . " in contest c" . $row['cid'] . ': ' . $chk_err . "\n";
        }
    }
    if (!$DB->q("MAYBEVALUE SELECT count(testcaseid) FROM testcase\n \t               WHERE input IS NOT NULL AND output IS NOT NULL AND\n \t               probid = %i", $row['probid'])) {
        $details .= 'p' . $row['probid'] . " in contest c" . $row['cid'] . ": missing in/output testcase.\n";
    }
}
foreach (array('input', 'output') as $inout) {
    $mismatch = $DB->q("SELECT probid, rank FROM testcase\n\t                    WHERE md5({$inout}) != md5sum_{$inout}");
    while ($r = $mismatch->next()) {
        $details .= 'p' . $r['probid'] . ": testcase #" . $r['rank'] . " MD5 sum mismatch between {$inout} and md5sum_{$inout}\n";
    }
}