solved=0;
$this->time=0;
$this->p_wa_num=array(0);
$this->p_ac_sec=array(0);
$this->p_pass_rate=array(0);
$this->total=0;
}
function Add($pid,$sec,$res,$result){
// echo "Add $pid $sec $res
";
if (isset($this->p_ac_sec[$pid])&&$this->p_ac_sec[$pid]>0)
return;
if ($result!=4){
if(isset($this->p_pass_rate[$pid])){
if($res>$this->p_pass_rate[$pid]){
$this->total-=$this->p_pass_rate[$pid]*100;
$this->p_pass_rate[$pid]=$res;
$this->total+=$this->p_pass_rate[$pid]*100;
}
}else{
$this->p_pass_rate[$pid]=$res;
$this->total+=$res*100;
}
if(isset($this->p_wa_num[$pid])){
$this->p_wa_num[$pid]++;
}else{
$this->p_wa_num[$pid]=1;
}
}else{
$this->p_ac_sec[$pid]=$sec;
$this->solved++;
if(!isset($this->p_wa_num[$pid])) $this->p_wa_num[$pid]=0;
if(isset($this->p_pass_rate[$pid])){
$this->total-=$this->p_pass_rate[$pid]*100;
}else{
$this->p_pass_rate[$pid]=$res*100;
}
$this->total+=$res*100;
$this->p_pass_rate[$pid]=$res;
$this->time+=$sec+$this->p_wa_num[$pid]*1200;
// echo "Time:".$this->time."
";
// echo "Solved:".$this->solved."
";
}
}
}
function s_cmp($A,$B){
// echo "Cmp....
";
if ($A->total!=$B->total) return $A->total<$B->total;
else {
if($A->solved!=$B->solved)
return $A->solved<$B->solved;
else
return $A->time>$B->time;
}
}
// contest start time
if (!isset($_GET['cid'])) die("No Such Contest!");
$cid=intval($_GET['cid']);
if($OJ_MEMCACHE){
$sql="SELECT `start_time`,`title`,`end_time` FROM `contest` WHERE `contest_id`='$cid'";
$result = mysql_query_cache($sql);
if($result) $rows_cnt=count($result);
else $rows_cnt=0;
}else{
$sql="SELECT `start_time`,`title`,`end_time` FROM `contest` WHERE `contest_id`=?";
$result = pdo_query($sql,$cid);
if($result) $rows_cnt=count($result);
else $rows_cnt=0;
}
$start_time=0;
$end_time=0;
if ($rows_cnt>0){
// $row=$result[0];
if($OJ_MEMCACHE)
$row=$result[0];
else
$row=$result[0];
$start_time=strtotime($row['start_time']);
$end_time=strtotime($row['end_time']);
$title=$row['title'];
$view_title = $title;
if(isset($_GET['down'])){
header ( "Content-type: application/excel" );
$ftitle=rawurlencode(preg_replace('/\.|\\\|\\/|\:|\*|\?|\"|\<|\>|\|/','',str_replace(' ','',$title)));
header ( "content-disposition: attachment; filename=contest".$cid."_".$ftitle.".xls" );
}
}
if ($start_time==0){
$view_errors= "No Such Contest";
require("template/".$OJ_TEMPLATE."/error.php");
exit(0);
}
if ($start_time>time()){
$view_errors= "$MSG_CONTEST $MSG_Contest_Pending!";
require("template/".$OJ_TEMPLATE."/error.php");
exit(0);
}
$noip = (time()<$end_time) && (stripos($title,$OJ_NOIP_KEYWORD)!==false);
if(isset($_SESSION[$OJ_NAME.'_'."administrator"])||
isset($_SESSION[$OJ_NAME.'_'."m$cid"])||
isset($_SESSION[$OJ_NAME.'_'."source_browser"])||
isset($_SESSION[$OJ_NAME.'_'."contest_creator"])
) $noip=false;
if ($noip) {
$view_errors = "