/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott *SCUJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott *result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception ("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ("http://cstest.scu.edu.cn/soj/solutions.action?userId=" + escapeURL(info->GetUsername()) + "&problemId=" + bott->Getvid()).c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row if (!RE2::PartialMatch(html, "(?s).*<table.*?<tr.*?(<tr.*?<td height=\"44\">.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)<td.*?>([0-9]*).*?<font.*?>(.*)</font>", &runid, &result)) { throw Exception("Failed to get current result."); } result = trim(result); if (isFinalResult(result)) { // result is the final one result = convertResult(result); if (!RE2::PartialMatch(status, "(?s)<td.*?>([0-9]*).*?<font.*?>.*</font>.*?<td>(.*?)</td>.*?<td>(.*?)</td>", &runid, &time_used, &memory_used)) { throw Exception ("Failed to parse details from status row."); } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(trim(time_used)); result_bott->Setmemory_used(trim(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } return result_bott; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * LOJJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, "http://www.lightoj.com/volume_usersubmissions.php"); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row if (!RE2::PartialMatch(html, "(?s)(<tr class=\"newone\">.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)sub_id=([0-9]*).*?<div.*?>(.*?)</div>", &runid, &result)) { throw Exception("Failed to get current result."); } result = trim(result); if (isFinalResult(result)) { // result is the final one result = convertResult(result); if (result != "Compile Error") { // no details for CE results if (!RE2::PartialMatch( status, "(?s)sub_id=([0-9]*).*?<td.*?<td.*?<td.*?<td.*?>(.*?)</td" ".*?<td.*?>(.*?)</td>", &runid, &time_used, &memory_used)) { throw Exception("Failed to parse details from status row."); } int time_ms = stringToDouble(time_used) * 1000 + 0.001; time_used = intToString(time_ms); } else { memory_used = time_used = "0"; } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(stringToInt(time_used)); result_bott->Setmemory_used(stringToInt(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } return result_bott; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * HRBUSTJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt( curl, CURLOPT_URL, ((string) "http://acm.hrbust.edu.cn/index.php?m=Status&a=" "showStatus&problem_id=" + escapeURL(bott->Getvid()) + "&user_name=" + escapeURL(info->GetUsername()) + "&language=" + convertLanguage(bott->Getlanguage())).c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row if (html.find("var is_login=\"\";") != string::npos || !RE2::PartialMatch(html, "(?s)<table class=\"ojlist\".*?<tr.*?(<tr.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)<td.*?<td>([0-9]*).*?<td.*?<td.*?>(.*?)</td>", &runid, &result)) { throw Exception("Failed to get current result."); } result = convertResult(trim(result)); if (isFinalResult(result)) { // result is the final one if (!RE2::PartialMatch(status, "(?s)>([0-9]*)ms.*?>([0-9]*)k", &time_used, &memory_used)) { throw Exception("Failed to parse details from status row."); } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(stringToInt(time_used)); result_bott->Setmemory_used(stringToInt(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } return result_bott; }
void HRBUSTJudger::getStatus() { // prepareCurl(); while (true) { stringstream sStream; string lang, outer_oj_id; char *lang_tmp, *outer_oj_id_tmp; sStream << judgeInfo.getLang(); sStream >> lang; sStream << judgeInfo.getId(); sStream >> outer_oj_id; string res_url = "http://acm.hrbust.edu.cn/index.php?m=Status&a=showStatus&problem_id=" + outer_oj_id + "&user_name=acmstep&language=" + lang; curl_easy_setopt(easy_handle, CURLOPT_URL, res_url.c_str()); cout << "Before performCurl()................." << endl; performCurl("tmpfiles/statusdata.html"); cout << "After performCurl()................." << endl; string res, runid, result, time_used, memory_used; string html = fileToString("tmpfiles/statusdata.html"); if (code != CURLE_OK) syslog(LOG_ERR, "getStatus failed."); else { if (html.find("var is_login=\"\";") != string::npos || !RE2::PartialMatch(html, "(?s)<table class=\"ojlist\".*?<tr.*?(<tr.*?</tr>)", &res)) { syslog(LOG_ERR, "[ERROR] HRBUSTJudger: Failed to get status row."); } if (!RE2::PartialMatch(res, "(?s)<td.*?<td>([0-9]*).*?<td.*?<td.*?>(.*?)</td>", &runid, &result)) { syslog(LOG_ERR, "[ERROR] HRBUSTJudger: Fail to get current result."); } result = convertResult(trim(result)); cout << "Result is: " << result << endl; if (isFinalResult(result)) { if (!RE2::PartialMatch(res, "(?s)>([0-9]*)ms.*?>([0-9]*)k", &time_used, &memory_used)) { syslog(LOG_ERR, "[ERROR] HRBUSTJudger: Failed to parse details from status row."); } cout << "0---------------------------------" << endl; cout << "Time used: " << time_used << " Memory_used: " << memory_used<< endl; judgeResult.setCodeId(judgeInfo.getCodeId()); judgeResult.setRunId(atoi(trim(runid).c_str())); judgeResult.setJudgeStatus(status_table[result]); judgeResult.setRunTime(atoi(trim(time_used).c_str())); judgeResult.setRunMemory(atoi(trim(memory_used).c_str())); cout << "[Result] Get JudgeStatus: " << judgeResult.getJudgeStatus() << endl; if (judgeResult.getJudgeStatus() == OJ_CE) { judgeResult.setErrorInfo(getCEinfo()); } else { judgeResult.setErrorInfo("NULL"); } break; } else { usleep(5000); } } } }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott *CCJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott *result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception ("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ((string) "http://www.codechef.com/get_submission_status/" + bott-> Getremote_runid()).c_str ()); performCurl(); string html = loadAllFromFile(tmpfilename); string result, time_used, memory_used; // get result if (!RE2::PartialMatch (html, "\"result_code\":\"(.*?)\"", &result)) { throw Exception("Failed to get current result."); } result = convertResult(result); if (isFinalResult(result)) { // if result if final, get details if (!RE2::PartialMatch(html, "(?s)\"time\":\"(.*?)\"", &time_used)) { throw Exception ("Failed to parse details from status row."); } int time_ms = stringToDouble(time_used) * 1000 + 0.001; int memory_kb; result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(intToString(time_ms)); if (result != "Compile Error") { // CodeChef will update Memory usage later in submission table // Weird... why don't they put in get_submission_status api... memory_used = "0"; prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ((string) "http://www.codechef.com/submissions?handle=" + escapeURL (info-> GetUsername ()) + "&pcode=" + escapeURL (bott->Getvid ())). c_str()); performCurl(); html = loadAllFromFile(tmpfilename); string status; if (!RE2::PartialMatch(html, "(?s)(<tr class=\"kol.*?<td width=\"60\">" + bott->Getremote_runid() + "</td>.*?</tr>)", &status)) { // Status row is not updated in time... log("Memory data not ready yet... Never mind, use 0 instead."); memory_used = "0"; } else if (!RE2::PartialMatch (status, ">([0-9\\.]*)M", &memory_used)) { memory_used = "0"; } memory_kb = stringToDouble(memory_used) * 1024 + 0.001; } result_bott->Setmemory_used(intToString(memory_kb)); result_bott->Setremote_runid(bott->Getremote_runid()); break; } } return result_bott; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * ZJUJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt( curl, CURLOPT_URL, ((string) "http://acm.zju.edu.cn/onlinejudge/showRuns.do?" "contestId=1&idStart=" + bott->Getremote_runid() + "&idEnd=" + bott->Getremote_runid()).c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string result, time_used, memory_used; // get first row if (!RE2::PartialMatch(html, "(?s)(<tr class=\"rowOdd\">.*?</tr>)", &status)) { continue; } // get result if (!RE2::PartialMatch( status, "(?s)<td class=\"runJudgeStatus\".*?<span.*?>(.*?)</span>", &result)) { throw Exception("Failed to get current result."); } result = trim(result); if (isFinalResult(result)) { // result is the final one result = convertResult(result); if (!RE2::PartialMatch( status, "(?s)<td class=\"runTime\".*?>(.*?)</td>.*" "<td class=\"runMemory\".*?>(.*?)</td>", &time_used, &memory_used)) { throw Exception("Failed to parse details from status row."); } result_bott = new Bott; result_bott->Setremote_runid(bott->Getremote_runid()); result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(stringToInt(time_used)); result_bott->Setmemory_used(stringToInt(memory_used)); if (result == "Compile Error") { // hack for ZJU, don't know why its submission id is inconsistent with // judge protocol if (!RE2::PartialMatch( status, "(?s)showJudgeComment\\.do\\?submissionId=([0-9]*)", &submission_id_for_ce)) { submission_id_for_ce = bott->Getremote_runid(); } } break; } } return result_bott; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott *NJUPTJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott *result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception ("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ((string) "http://acm.njupt.edu.cn/acmhome/showstatus.do"). c_str()); string post = (string) "problemId=" + bott->Getvid() + "&languageS=" + escapeURL(bott->Getlanguage()) + "&userName="******"&resultS=All"; curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row if (!RE2::PartialMatch (html, "(?s)<table.*?</thead>.*?(<tr.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)method=showdetail.*?value=\"(.*?)\".*?<b acc=\"acc\"></b>\\s*(.*?)\\s*<b acc=\"acc\"></b>", &runid, &result)) { throw Exception("Failed to get current result."); } result = convertResult(trim(result)); if (isFinalResult(result)) { // result is the final one, get details if (result == "Accepted") { // only accepted run has details if (!RE2::PartialMatch(status, "(?s)([0-9]*)<b ms=\"ms\"></b>MS.*?([0-9]*)<b k=\"k\"></b>K", &time_used, &memory_used)) { throw Exception ("Failed to parse details from status row."); } } else { memory_used = time_used = "0"; } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(convertResult(result)); result_bott->Settime_used(trim(time_used)); result_bott->Setmemory_used(trim(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } return result_bott; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * SPOJJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ("http://www.spoj.com/status/" + info->GetUsername() + "/ajax=1").c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row if (!RE2::PartialMatch(html, "(?s)(<tr class=\"kol.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)statusres_([0-9]*).*?>\\w*(?:<.*?>)?(.*?)\\w*<span", &runid, &result)) { throw Exception("Failed to get current result."); } result = trim(result); if (isFinalResult(result)) { // result is the final one result = convertResult(result); if (result == "Accepted" || result == "Runtime Error" || result == "Wrong Answer") { // only have details for these three results string unit; if (!RE2::PartialMatch( status, "(?s)statustime_.*?<a.*?>(.*?)</a>.*?statusmem_.*?>\\s*(.*?)(M|k)", &time_used, &memory_used, &unit)) { throw Exception("Failed to parse details from status row."); } int time_ms = stringToDouble(time_used) * 1000 + 0.001; time_used = intToString(time_ms); if (unit == "M") { int memory_mb = stringToDouble(memory_used) * 1024 + 0.001; memory_used = intToString(memory_mb); } } else { time_used = memory_used = "0"; } result_bott = new Bott; result_bott->Setremote_runid(runid); result_bott->Settype(RESULT_REPORT); result_bott->Setresult(result); result_bott->Settime_used(stringToInt(time_used)); result_bott->Setmemory_used(stringToInt(memory_used)); break; } } return result_bott; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * AizuJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt( curl, CURLOPT_URL, ((string) "http://judge.u-aizu.ac.jp/onlinejudge/status.jsp").c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first row of current user if (!RE2::PartialMatch( html, "(?s)(<tr *class=\"dat\".*?>" + info->GetUsername() + "<.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } html = status; if (!RE2::PartialMatch( html, "(?s).*(<tr *class=\"dat\".*?>" + info->GetUsername() + "<.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch( status, "(?s)rid=([0-9]*).*status.*?<a href=\"review.*?>(.*?)</a>", &runid, &result)) { throw Exception("Failed to get current result."); } result = convertResult(trim(result)); if (isFinalResult(result)) { // result is the final one, get details if (result != "Runtime Error" && result != "Compile Error") { if (!RE2::PartialMatch( status, "(?s)<td class=\"text-center\">([0-9\\.]*) s.*?<td.*?>([0-9]*) KB", &time_used, &memory_used)) { throw Exception("Failed to parse details from status row."); } } else { memory_used = time_used = "0"; } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(convertResult(result)); result_bott->Settime_used( (int)(stringToDouble(time_used) * 100 + 0.1)); result_bott->Setmemory_used(stringToInt(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } return result_bott; }
/** * Get result and related info * @param bott Original Bott info * @return Result Bott file */ Bott * CFJudger::getStatus(Bott * bott) { time_t begin_time = time(NULL); Bott * result_bott; while (true) { // check wait time if (time(NULL) - begin_time > info->GetMax_wait_time()) { throw Exception("Failed to get current result, judge time out."); } prepareCurl(); curl_easy_setopt(curl, CURLOPT_URL, ((string) "http://codeforces.com/submissions/" + info->GetUsername()).c_str()); performCurl(); string html = loadAllFromFile(tmpfilename); string status; string runid, result, time_used, memory_used; // get first result row if (!RE2::PartialMatch(html, "(?s)<tr.*first-row.*?(<tr.*?</tr>)", &status)) { throw Exception("Failed to get status row."); } // get result if (!RE2::PartialMatch(status, "(?s)status-cell.*?>(.*?)</td>", &result)) { throw Exception("Failed to get current result."); } if (isFinalResult(result)) { // if result if final, get details if (!RE2::PartialMatch( status, "(?s)data-submission-id=\"([0-9]*)\".*submissionVerdict" "=\"(.*?)\".*time-consumed-cell.*?>(.*?) ms.*memory-consumed" "-cell.*?>(.*?) KB", &runid, &result, &time_used, &memory_used)) { // try api when failed log("Failed to parse details from status row, try API."); prepareCurl(); curl_easy_setopt( curl, CURLOPT_URL, ((string) "http://codeforces.com/api/user.status?handle=" + info->GetUsername() + "&from=1&count=1").c_str()); performCurl(); string json = loadAllFromFile(tmpfilename); if (!RE2::PartialMatch( json, "(?s)\"id\":([0-9]*)\"verdict\":\"(.*?)\".*\"timeConsumed" "Millis\":([0-9]*),\"memeryConsumedBytes\":([0-9]*)", &runid, &result, &time_used, &memory_used)) { throw Exception("Failed to parse details from API."); } } result_bott = new Bott; result_bott->Settype(RESULT_REPORT); result_bott->Setresult(convertResult(result)); result_bott->Settime_used(stringToInt(time_used)); result_bott->Setmemory_used(stringToInt(memory_used)); result_bott->Setremote_runid(trim(runid)); break; } } // for CodeForces, we can store extra infos in ce_info column string contest; // no need to check fail or not, since submit function has already done it RE2::PartialMatch(bott->Getvid(), "(^[0-9]{1,6})", &contest); if (result_bott->Getresult() != "Accepted" && result_bott->Getresult() != "Compile Error") { result_bott->Setce_info( getVerdict(contest, result_bott->Getremote_runid())); } return result_bott; }