예제 #1
0
 @Override
 public PCMSTeamInfo getParticipant(int id) {
   for (PCMSTeamInfo team : standings) {
     if (team.getId() == id) {
       return team;
     }
   }
   return null;
 }
예제 #2
0
 @Override
 public PCMSTeamInfo getParticipantByHashTag(String hashTag) {
   for (PCMSTeamInfo teamInfo : standings) {
     if (hashTag != null && hashTag.equalsIgnoreCase(teamInfo.getHashTag())) {
       return teamInfo;
     }
   }
   return null;
 }
예제 #3
0
  public TeamInfo[] getPossibleStandings(boolean optimistic) {
    TeamInfo[] original = getStandings();

    PCMSTeamInfo[] standings = new PCMSTeamInfo[original.length];
    for (int i = 0; i < original.length; i++) {
      standings[i] = (PCMSTeamInfo) original[i].copy();
      List<RunInfo>[] runs = original[i].getRuns();
      for (int j = 0; j < problemNumber; j++) {
        int runIndex = 0;
        for (RunInfo run : runs[j]) {
          PCMSRunInfo clonedRun = new PCMSRunInfo(run);

          if (clonedRun.getResult().length() == 0) {
            clonedRun.judged = true;
            String expectedResult = optimistic ? "AC" : "WA";
            clonedRun.result = runIndex == runs[j].size() - 1 ? expectedResult : "WA";
            clonedRun.reallyUnknown = true;
          }
          standings[i].addRun(clonedRun, j);
          runIndex++;
        }
      }
    }
    for (PCMSTeamInfo team : standings) {
      team.solved = 0;
      team.penalty = 0;
      team.lastAccepted = 0;
      List<RunInfo>[] runs = team.getRuns();
      for (int j = 0; j < problemNumber; j++) {
        int wrong = 0;
        for (RunInfo run : runs[j]) {
          if ("AC".equals(run.getResult())) {
            team.solved++;
            int time = (int) (run.getTime() / 60 / 1000);
            team.penalty += wrong * 20 + time;
            team.lastAccepted = Math.max(team.lastAccepted, run.getTime());
            break;
          } else if (run.getResult().length() > 0 && !"CE".equals(run.getResult())) {
            wrong++;
          }
        }
      }
    }

    Arrays.sort(standings, TeamInfo.comparator);

    for (int i = 0; i < standings.length; i++) {
      if (i > 0 && TeamInfo.comparator.compare(standings[i - 1], standings[i]) == 0) {
        standings[i].rank = standings[i - 1].rank;
      } else {
        standings[i].rank = i + 1;
      }
    }
    return standings;
  }
예제 #4
0
 void addTeamStandings(PCMSTeamInfo teamInfo) {
   standings.add(teamInfo);
   positions.put(teamInfo.getAlias(), standings.size() - 1);
   teamNumber = standings.size();
 }