コード例 #1
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;
  }
コード例 #2
0
  @Override
  protected SubmissionRemoteStatus query(SubmissionInfo info) {
    DedicatedHttpClient client =
        dedicatedHttpClientFactory.build(getOjInfo().mainHost, null, getOjInfo().defaultChaset);
    String html = client.get("/status.aspx?space=1&from=" + info.remoteRunId).getBody();

    String regex =
        "<TD.*?>"
            + info.remoteRunId
            + "</TD>"
            + ".+?"
            + "<TD class=\"verdict_\\w{2,}\">(.+?)</TD>"
            + "<TD.*?>(.+?)</TD>"
            + "<TD.*?>(.+?)</TD>"
            + "<TD.*?>(.+?)</TD>";
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(html);
    Validate.isTrue(matcher.find());

    SubmissionRemoteStatus status = new SubmissionRemoteStatus();
    status.rawStatus = matcher.group(1).replaceAll("<.*?>", "").trim();
    status.statusType = SubstringNormalizer.DEFAULT.getStatusType(status.rawStatus);

    try {
      status.failCase = Integer.parseInt(matcher.group(2).replaceAll("\\D+", ""));
    } catch (Exception e) {
    }

    try {
      status.executionTime = (int) (Double.parseDouble(matcher.group(3)) * 1000 + 0.5);
    } catch (Exception e) {
    }

    try {
      status.executionMemory = Integer.parseInt(matcher.group(4).replaceAll("\\D+", ""));
    } catch (Exception e) {
    }

    if (status.statusType == RemoteStatusType.CE) {
      String ceUrl = "/ce.aspx?id=" + info.remoteRunId;
      HttpEntity entity =
          SimpleNameValueEntityFactory.create(
              "Action",
              "login", //
              "Source",
              ceUrl, //
              "JudgeID",
              info.remoteAccountId //
              );
      client.post("/auth.aspx", entity, HttpStatusValidator.SC_MOVED_TEMPORARILY);
      html = client.get(ceUrl).getBody();
      status.compilationErrorInfo = "<pre>" + html + "</pre>";
    }
    return status;
  }