Example #1
0
 public function writedb_single()
 {
     $p = new DataAccess();
     $ac = $this->ac == $this->info['datacnt'] ? 1 : 0;
     if ($this->info['rejudge'] == 1) {
         $sql = "update submit set result='{$this->s_detail}' ,score='{$this->s_score}' ,memory='{$this->avgmemory}' ,accepted='{$ac}' ,runtime='{$this->totaltime}' where sid='{$this->info['sid']}'";
         $p->dosql($sql);
     } else {
         $sql = "update problem set submitcnt=submitcnt+1";
         if ($ac) {
             $sql .= ",lastacid={$this->info['uid']}";
             $sql2 = "select accepted from submit where pid='{$this->info['pid']}' and uid='{$this->info['uid']}' and accepted=1";
             $first = $p->dosql($sql2) == 0;
             if ($first) {
                 //第一次AC
                 $sql .= " ,acceptcnt=acceptcnt+1";
             }
         }
         $sql .= " where pid={$this->info['pid']}";
         $p->dosql($sql);
         $sql = "insert into submit(pid,uid,lang,result,score,memory,accepted,subtime,IP,runtime,srcname) values({$this->info['pid']},{$this->info['uid']},{$this->info['language']},'{$this->s_detail}',{$this->s_score},{$this->avgmemory},{$ac}," . time() . ",'{$_SERVER['REMOTE_ADDR']}',{$this->totaltime},'{$this->srcname}')";
         $p->dosql($sql);
     }
     calc_grade($this->info['uid'], get_problem_diffarr());
 }
Example #2
0
    $d=$rand_gen_data_access->rtnrlt($i);
    $subcnt[ $d['pid'] ]++;
    if ($d['accepted'])
        $accnt[ $d['pid'] ]++;
    if ($d['pid']>$lastprob)
        $lastprob=$d['pid'];
}
    flush();
$probs=$lastprob;
for ($i=1;$i<=$probs;$i++) {
    $sql="update problem set acceptcnt='{$accnt[$i]}',submitcnt='{$subcnt[$i]}' where pid='{$i}'";
    $rand_gen_data_access->dosql($sql);
}
    flush();
*/
$diffarr = get_problem_diffarr();
$p = new DataAccess();
$sql = "select uid, usr, realname from userinfo";
$cnt = $p->dosql($sql);
for ($i = 0; $i < $cnt; $i++) {
    $d = $p->rtnrlt($i);
    $uid = (int) $d['uid'];
    $username = $d['realname'];
    $arr = calc_grade($uid, $diffarr);
    $submt = $arr[0];
    $accpd = $arr[1];
    $grade = $arr[2];
    if ($grade > 0) {
        echo "{$username} = <span class=ok>{$grade}</span> ";
        //<br />";
        echo "(<span class=no>{$accpd}</span>/";