bool doCmd(const char* path, enum CmdType cmd_type, enum FileType file_type, CacheStat* pStat){ int fd = 0; DIR *dir = NULL; DIR *soft_dir = NULL; struct dirent *dp = NULL; char file_name[256]; char link_name[256]; char real_path[256]; void *pbase = NULL; char *vec = NULL; struct stat st; int in_cache = 0; int str_len = 0; int page_index; int page_count; int pagesize = getpagesize(); int time_used = 0; struct timeval begin, end; if(realpath(path, real_path) == NULL){ goto ERROR; } if(file_type == REGFILE){ fd = open(real_path, O_RDONLY); if(fd<0){ goto ERROR; } if(stat(real_path, &st)<0){ goto ERROR; } switch(cmd_type){ case CLEAR: if(posix_fadvise(fd, 0, st.st_size, POSIX_FADV_DONTNEED) != 0){ goto ERROR; } fprintf(stdout, "Release:%s\n", real_path); break; case STAT: if(st.st_size == 0) goto EMPTYFILE; pbase = mmap((void *)0, st.st_size, PROT_NONE, MAP_SHARED, fd, 0); if(pbase == MAP_FAILED){ goto ERROR; } page_count = (st.st_size+pagesize-1)/pagesize; vec = (char*)calloc(1, page_count); if(mincore(pbase, st.st_size, (unsigned char *)vec) != 0){ goto ERROR; } for(page_index=0; page_index<page_count; page_index++){ if(vec[page_index]&1 != 0){ ++in_cache; } } pStat->page_count += page_count; pStat->in_cache += in_cache; EMPTYFILE: if(pStat->is_print == true){ fprintf(stdout, "Stat:%s size:%s cached:%s\n", real_path, sizeFit(st.st_size, buf1), sizeFit(in_cache*(pagesize), buf2)); } break; case LOCK: if(st.st_size == 0){ fprintf(stderr, "Empty file %s\n", real_path); return true; } pbase = mmap((void *)0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); if(pbase == MAP_FAILED){ goto ERROR; } if(mlock(pbase, st.st_size) == 0){ fprintf(stdout, "Lock %s succeed, size:%s\n", real_path, sizeFit(st.st_size, buf1)); return true; }else{ goto ERROR; } case WARM: gettimeofday(&begin, NULL); if(posix_fadvise(fd, 0, st.st_size, POSIX_FADV_WILLNEED) != 0){ goto ERROR; } gettimeofday(&end, NULL); time_used = getUsedTime(&begin, &end); fprintf(stdout, "Warmup File:%s TimeUsed:%d ms\n", real_path, time_used); break; default: fprintf(stderr, "do not support cmd type %d\n", cmd_type); goto ERROR; } close(fd); if(vec) free(vec); if(pbase) munmap(pbase, st.st_size); return true; }else if(file_type == DIRECTORY){ if((dir = opendir(real_path)) == NULL){ goto ERROR; } gettimeofday(&begin, NULL); while((dp = readdir(dir)) != NULL){ if(strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0){ memset(file_name, 0, sizeof(file_name)); strcat(file_name, real_path); strcat(file_name, "/"); strcat(file_name, dp->d_name); if(dp->d_type == DT_REG){ doCmd(file_name, cmd_type, REGFILE, pStat); }else if(dp->d_type == DT_DIR){ doCmd(file_name, cmd_type, DIRECTORY, pStat); }else if(dp->d_type == DT_LNK){ if(realpath(file_name, link_name) != NULL){ if(stat(link_name, &st)<0){ goto ERROR; } if(st.st_mode & S_IFREG){ doCmd(file_name, cmd_type, REGFILE, pStat); }else if(st.st_mode & S_IFDIR){ doCmd(file_name, cmd_type, DIRECTORY, pStat); } } }else{ fprintf(stdout, "%s:%c type unsupported!\n", dp->d_name, dp->d_type); } } } gettimeofday(&end, NULL); time_used = getUsedTime(&begin, &end); if(cmd_type == WARM){ fprintf(stdout, "Warmup Dir:%s TimeUsed:%d ms\n", real_path, time_used); } closedir(dir); return true; } ERROR: fprintf(stderr, "File:%s %s\n", real_path, strerror(errno)); if(fd) close(fd); if(dir) closedir(dir); if(vec) free(vec); if(pbase) munmap(pbase, st.st_size); return false; }
bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { int begin=time(NULL); string runid; tu=mu="0"; string ts; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "loj.cookie"); string url=(string)"http://www.lightoj.com/volume_usersubmissions.php"; //cout<<url; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getResFromFile(tfilename); if (ts=="") return false; writelog((char *)ts.c_str()); runid=getRunid(ts); result=getResult(ts); //cout << result; if (result.find("Not")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos ) { break; } if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("Not")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos)) return false; //cout<<runid<<" "<<tu<<" "<<mu<<" "<<result<<endl; if (result=="Compilation Error") ce_info=getCEinfo(runid); else { tu=getUsedTime(ts); mu=getUsedMem(ts); ce_info=""; } //cout<<ce_info; if (result!="Accepted"&&result[result.length()-1]=='d') { result.erase(result.end()-2,result.end()); } result=convertResult(result); return true; }
bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { usleep(600000); int begin=time(NULL); string runid; tu=mu="0"; string ts; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "sgu.cookie"); string url=(string)"http://acm.sgu.ru/status.php?id="+username+"&idmode=1&problem="+pid; //cout<<url; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getResFromFile(tfilename); if (ts=="") return false; //cout<<ts; runid=getRunid(ts); result=getResult(ts); //cout << result; if (result.find("queue")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Waiting")==string::npos &&result.find("Compiling")==string::npos &&result.length()>4) { break; } if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("queue")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Waiting")==string::npos &&result.find("Compiling")==string::npos &&result.length()>4)) return false; tu=getUsedTime(ts); mu=getUsedMem(ts); //cout<<runid<<" "<<tu<<" "<<mu<<" "<<result<<endl; result=convertResult(result); if (result=="Compile Error") ce_info=getCEinfo(runid); else ce_info=""; //cout<<ce_info; return true; }
//http://poj.org/status?problem_id=1000&user_id=51isoft&result=&language= bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { int begin=time(NULL); string runid; tu=mu="0"; string ts; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "pku.cookie"); string url=(string)"http://poj.org/status?problem_id="+pid+"&user_id="+username+"&language="+lang; //cout<<url; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getLineFromFile(tfilename,3); //cout<<ts; /*if (ts.find("alert(\"Login failed!)")!=string::npos) return false; */ if (ts.find("Error Occurred")!=string::npos||ts.find("The page is temporarily unavailable")!=string::npos) return false; runid=getRunid(ts); result=getResult(ts); //cout << result; if (result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos &&result!=""&&result[0]!='\n'&&result[0]!='\t'&&result[0]!='\r'&&result[0]!=' ') { break; } if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos &&result!=""&&result[0]!='\n'&&result[0]!='\t'&&result[0]!='\r'&&result[0]!=' ')) return false; if (result=="Compile Error") { result = "Compilation Error"; ce_info=getCEinfo(runid); } else ce_info=""; if (result=="Accepted") { tu=getUsedTime(ts); mu=getUsedMem(ts); } else if (result[result.length()-1]=='d') { //result.erase(result.end()-2,result.end()); } return true; }
//http://acm.fzu.edu.cn/log.php?pid=1000&user=bnuvjudge&language=1 bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { int begin=time(NULL); string runid; tu=mu="0"; string ts; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "fzu.cookie"); string url=(string)"http://acm.fzu.edu.cn/log.php?user="******"&pid="+pid; //cout<<url<<endl; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getResFromFile(tfilename); //cout<<ts; if (ts.find("Error Occurred")!=string::npos||ts.find("The page is temporarily unavailable")!=string::npos) return false; runid=getRunid(ts); result=getResult(ts); //cout << result; if (result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos) { break; } if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos)) return false; result=convertResult(result); if (result=="Compile Error") ce_info=getCEinfo(runid); else ce_info=""; if (result=="Accepted") { tu=getUsedTime(ts); mu=getUsedMem(ts); } return true; }
//http://acm.nbut.cn/Problem/status.xhtml?username=bnuvjudge&problemid=1000&language=1 bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { int begin=time(NULL); string runid; tu=mu="0"; string ts; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "nbut.cookie"); string url=(string)"http://acm.nbut.cn/Problem/status.xhtml?username="******"&problemid="+pid+"&language="+lang; //cout<<url<<endl; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getResFromFile(tfilename); //cout<<ts; if (ts.find("Error Occurred")!=string::npos||ts.find("The page is temporarily unavailable")!=string::npos) return false; runid=getRunid(ts); result=getResult(ts); //cout << result; if (result.find("WAITING")==string::npos &&result.find("RUNNING")==string::npos &&result.find("JUDGING")==string::npos &&result.find("QUEUING")==string::npos &&result.find("COMPILING")==string::npos) { break; } if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("WAITING")==string::npos &&result.find("RUNNING")==string::npos &&result.find("JUDGING")==string::npos &&result.find("QUEUING")==string::npos &&result.find("COMPILING")==string::npos)) return false; result=convertResult(result); if (result=="Compile Error") ce_info=getCEinfo(runid); else ce_info=""; tu=getUsedTime(ts); mu=getUsedMem(ts); return true; }
bool warmup(const char *path, enum FileType file_type){ int fd = 0; DIR *dir = NULL; int time_used = 0; char file_name[256]; struct stat st; struct timeval begin, end; struct dirent *dp = NULL; if(stat(path, &st)<0){ goto ERROR; } gettimeofday(&begin, NULL); if(file_type == REGFILE){ fd = open(path, O_RDONLY); if(fd<0){ goto ERROR; } if(posix_fadvise(fd, 0, st.st_size, POSIX_FADV_WILLNEED) != 0){ goto ERROR; } }else if(file_type == DIRECTORY){ if((dir = opendir(path)) == NULL){ goto ERROR; } while((dp = readdir(dir)) != NULL){ if(dp->d_name[0] != '.'){ memset(file_name, 0, sizeof(path)); strcat(file_name, path); strcat(file_name, "/"); strcat(file_name, dp->d_name); if(dp->d_type == DT_REG){ warmup(file_name, REGFILE); }else if(dp->d_type == DT_DIR){ warmup(file_name, DIRECTORY); }else{ fprintf(stdout, "%s:%c type unsupported!\n", dp->d_name, dp->d_type); } } } } gettimeofday(&end, NULL); time_used = getUsedTime(&begin, &end); if(file_type == REGFILE){ fprintf(stdout, "Warmup File:%s TimeUsed:%d ms\n", path, time_used); close(fd); }else if(file_type == DIRECTORY){ fprintf(stdout, "Warmup Dir:%s TimeUsed:%d ms\n", path, time_used); closedir(dir); } return true; ERROR: fprintf(stderr, "File:%s %s\n", path, strerror(errno)); if(fd) close(fd); if(dir) closedir(dir); return false; }
//http://acm.hdu.edu.cn/status.php?first=&pid=1000&user=bnuvjudge&lang=1&status=0 bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { int begin=time(NULL); string runid=getRealRunid(); //cout<<runid; tu=mu="0"; string ts; while (true) { if (time(NULL)-begin>MAX_WAIT_TIME) break; FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "uvalive.cookie"); curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl"); string url=(string)"http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9"; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getFirstFromFile(tfilename); if (ts.find("<b>One or more following ERROR(s) occurred.")!=string::npos||ts.find("The page is temporarily unavailable")!=string::npos) return false; writelog((char *)ts.c_str()); writelog((char *)(runid+"\n").c_str()); if (runid!=getRunid(ts)) continue; result=getResult(ts); //cout << result <<endl; if (result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("judge")==string::npos &&result.find("Queuing")==string::npos &&result.find("queue")==string::npos &&result.find("Compiling")==string::npos &&result.find("Received")==string::npos &&result.find("Linking")==string::npos &&result.find("Submission error")==string::npos &&result!=""&&result[0]!='\t'&&result[0]!=' ') { break; } } if (!(result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("judge")==string::npos &&result.find("Queuing")==string::npos &&result.find("queue")==string::npos &&result.find("Compiling")==string::npos &&result.find("Linking")==string::npos &&result.find("Received")==string::npos &&result.find("Submission error")==string::npos &&result!=""&&result[0]!='\t'&&result[0]!=' ')) return false; if (result=="Compilation error") { result="Compile Error"; ce_info=getCEinfo(runid); } else ce_info=""; tu=getUsedTime(ts); mu=getUsedMem(ts); if (mu=="") mu="0"; if (result!="Accepted"&&result[result.length()-1]=='d') { result.erase(result.end()-2,result.end()); } for (int i=0;i<result.length();i++) { if (result[i]==' ') { if (result[i+1]>='a'&&result[i+1]<='z') result[i+1]+='A'-'a'; } } return true; }
//http://acm.hdu.edu.cn/status.php?first=&pid=1000&user=tjuvjudge&lang=1&status=0 bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { int begin=time(NULL); string runid; tu=mu="0"; string ts; int tried=0; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "hdu.cookie"); string url=(string)"http://acm.hdu.edu.cn/status.php?first=&pid="+pid+"&user="******"&lang=&status=0"; //cout<<url; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getLineFromFile(tfilename,77); //cout<<ts; //writelog((char *)ts.c_str()); /*if (ts.find("alert(\"Login failed!)")!=string::npos) return false; */ if (ts.find("Connect(0) to MySQL Server failed.")!=string::npos||ts.find("<b>One or more following ERROR(s) occurred.")!=string::npos||ts.find("<h2>The requested URL could not be retrieved</h2>")!=string::npos||ts.find("PHP: Maximum execution time of")!=string::npos) { tried++; if (tried>=MAX_TRY_TIME) return false; continue; } runid=getRunid(ts); result=getResult(ts); /* minjie */ db_client.update("toj.Status", BSON("run_ID" << temp.runid), BSON("$set" << BSON("result"<<result)), true, false); //upsert, multi cout << result<<endl<<runid<<endl; if (result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos &&result.find("\n")&&result!="") { break; } /* minjie */ //if (time(NULL)-begin>30) sleep(500); if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos)) return false; if(result=="Compilation Error") ce_info = getCEinfo(runid); else ce_info=""; tu=getUsedTime(ts); mu=getUsedMem(ts); /* minjie update Status */ db_client.update("toj.Status", BSON("run_ID" << temp.runid), BSON("$set" << BSON("vrun_ID" << runid << "oj" << "HDU" << "result"<<result<<"time_used"<<tu<<"mem_used"<<mu<<"ce_info"<<ce_info)), true, false); /* minjie update User */ db_client.update("toj.User", BSON("username" << temp.user), BSON("$inc"<<BSON("total_submit"<<1)), false,true); //upsert,multi if(result == "Accepted") { db_client.update("toj.User", BSON("username" << temp.user), BSON("$inc"<<BSON("total_ac"<<1)), false,true); /* update speed */ bson::bo obj = db_client.findOne("toj.Status", BSON("username" << temp.user << "pid" << temp.pid << "speed" << 51)); bool fast = false; if(obj.isEmpty()) fast = true; else { int time_used = boost::lexical_cast<int>(obj.getStringField("time_used")); int mem_used = boost::lexical_cast<int>(obj.getStringField("mem_used")); int now_tu = boost::lexical_cast<int>(tu); int now_mu = boost::lexical_cast<int>(mu); if(now_tu < time_used || (now_tu == time_used && now_mu < mem_used)) fast = true; } if(fast) { db_client.update("toj.Status", BSON("username" << temp.user << "pid" << temp.pid), BSON("$set" << BSON("speed" << 50)), true, false); db_client.update("toj.Status", BSON("run_ID" << temp.runid), BSON("$set" << BSON("speed" << 51)), true, false); } } /* minjie update Problem */ db_client.update("toj.Problem", BSON("pid" << temp.pid), BSON("$inc"<<BSON("total_submit"<<1)), false,true); //upsert,multi string dbresult; switch(result[0]) { case 'A': dbresult = "total_ac"; break; case 'W': dbresult = "total_wa"; break; case 'P': dbresult = "total_pe"; break; case 'C': dbresult = "total_ce"; break; case 'R': dbresult = "total_re"; break; case 'T': dbresult = "total_tle"; break; case 'M': dbresult = "total_mle"; break; case 'O': dbresult = "total_ole"; break; default: dbresult = "total_other"; break; } db_client.update("toj.Problem", BSON("pid" << temp.pid), BSON("$inc"<<BSON(dbresult<<1)), false,true); //upsert,multi return true; }
//http://acm.hdu.edu.cn/status.php?first=&pid=1000&user=bnuvjudge&lang=1&status=0 bool getStatus(string pid,string lang,string & result,string& ce_info,string &tu,string &mu) { int begin=time(NULL); string runid; tu=mu="0"; string ts; int tried=0; while (true) { FILE * fp=fopen(tfilename,"w+"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "hdu.cookie"); string url=(string)"http://acm.hdu.edu.cn/status.php?first=&pid="+pid+"&user="******"&lang=&status=0"; //cout<<url; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; ts=getLineFromFile(tfilename,77); //cout<<ts; //writelog((char *)ts.c_str()); /*if (ts.find("alert(\"Login failed!)")!=string::npos) return false; */ if (ts.find("Connect(0) to MySQL Server failed.")!=string::npos||ts.find("<b>One or more following ERROR(s) occurred.")!=string::npos||ts.find("<h2>The requested URL could not be retrieved</h2>")!=string::npos||ts.find("PHP: Maximum execution time of")!=string::npos) { tried++; if (tried>=MAX_TRY_TIME) return false; continue; } runid=getRunid(ts); result=getResult(ts); cout << result<<endl<<runid<<endl; if (result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos &&result.find("\n")&&result!="") { break; } if (time(NULL)-begin>MAX_WAIT_TIME) break; } if (!(result.find("Waiting")==string::npos &&result.find("Running")==string::npos &&result.find("Judging")==string::npos &&result.find("Queuing")==string::npos &&result.find("Compiling")==string::npos)) return false; if (result=="Compilation Error") { //result="Compile Error"; ce_info=getCEinfo(runid); } else ce_info=""; tu=getUsedTime(ts); mu=getUsedMem(ts); /* if (result != "Accepted" && result[result.length()-1] == 'd') { result.erase(result.end()-2,result.end()); } */ return true; }