Пример #1
0
 @Override
 protected void populateProblemInfo(RawProblemInfo info, String problemId, String html) {
   info.title = Tools.regFind(html, "<h1 class=\"title\">(?:.+</a> -)?([\\s\\S]*?)</h1>").trim();
   info.timeLimit = 1000 * Integer.parseInt(Tools.regFind(html, "Time Limit : (\\d+) sec"));
   info.memoryLimit = Integer.parseInt(Tools.regFind(html, "Memory Limit : (\\d+) KB"));
   info.description =
       Tools.regFind(html, "<div class=\"description\">([\\s\\S]*?)<hr />")
           .replaceAll("^[\\s\\S]*</h1>", "");
   info.source = Tools.regFind(html, "style=\"font-size:10pt\">\\s*Source:([\\s\\S]*?)</div>");
 }
Пример #2
0
  @Override
  protected SubmissionRemoteStatus query(
      SubmissionInfo info, RemoteAccount remoteAccount, DedicatedHttpClient client) {
    String html =
        client
            .get(
                "/onlinejudge/showRuns.do?contestId=1&lastId="
                    + (Integer.parseInt(info.remoteRunId) + 1))
            .getBody();
    Pattern pattern =
        Pattern.compile(
            "<td class=\"runId\">"
                + info.remoteRunId
                + "[\\s\\S]*?judgeReply\\w{2,5}\">([\\s\\S]*?)</span>[\\s\\S]*?runTime\">([\\s\\S]*?)</td>[\\s\\S]*?runMemory\">([\\s\\S]*?)</td>");
    Matcher matcher = pattern.matcher(html);
    Validate.isTrue(matcher.find());

    SubmissionRemoteStatus status = new SubmissionRemoteStatus();
    status.rawStatus = matcher.group(1).replaceAll("<[\\s\\S]*?>", "").trim();
    status.statusType = SubstringNormalizer.DEFAULT.getStatusType(status.rawStatus);
    if (status.statusType == RemoteStatusType.AC) {
      status.executionMemory = Integer.parseInt(matcher.group(3));
      status.executionTime = Integer.parseInt(matcher.group(2));
    } else if (status.statusType == RemoteStatusType.CE) {
      String wierdRunId = Tools.regFind(matcher.group(1), "submissionId=(\\d+)");
      html = client.get("/onlinejudge/showJudgeComment.do?submissionId=" + wierdRunId).getBody();
      status.compilationErrorInfo = "<pre>" + html + "</pre>";
    }
    return status;
  }