コード例 #1
0
  private void readProblemInfo(String pathName) {
    ProblemManager problemManager = new ProblemManager();
    File file = new File(pathName);
    try (BufferedReader br = new BufferedReader(new FileReader(file))) {
      String line;
      while ((line = br.readLine()) != null) {
        String[] sp = line.split(",");
        String input = MyUtil.readFromFile(new File(sp[1]));
        String output = MyUtil.readFromFile(new File(sp[2]));
        int timeLimit = Integer.valueOf(sp[3]);
        int memoryLimit = Integer.valueOf(sp[4]);
        String judgeMethod = "";
        if (sp.length == 6) judgeMethod = MyUtil.readFromFile(new File(sp[5]));

        Map<String, String> pinfo = new HashMap<String, String>();
        this.problems.put(sp[0], new ProblemInfo(sp[0], timeLimit, memoryLimit, 0));
        pinfo.put("problem_id", sp[0]);
        pinfo.put("time_limit", String.valueOf(timeLimit));
        pinfo.put("memory_limit", String.valueOf(memoryLimit));
        pinfo.put("special_judge", judgeMethod);
        pinfo.put("input", input);
        pinfo.put("output", output);
        pinfo.put("time_stamp", "0");
        problemManager.addEntry(pinfo);
      }
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
コード例 #2
0
  private void readConfigure() throws FileNotFoundException {
    ConfigureManager configureManager = new ConfigureManager();
    AccountManager accountManager = new AccountManager();
    ProblemManager problemManager = new ProblemManager();
    SubmissionManager submissionManager = new SubmissionManager();
    QAManager qaManager = new QAManager();
    ClarificationManager clarificationManager = new ClarificationManager();
    Map<String, String> config = new HashMap<String, String>();

    configureManager.createTable();
    accountManager.createTable();
    problemManager.createTable();
    submissionManager.createTable();
    qaManager.createTable();
    clarificationManager.createTable();
    this.port = 8888;
    this.scoreBoardPort = 8889;
    // default port

    File file = new File("config.txt");
    try (BufferedReader br = new BufferedReader(new FileReader(file))) {
      String line;
      while ((line = br.readLine()) != null) {
        String[] sp = line.split(":");
        if (sp[0].equals("port")) this.port = Integer.valueOf(sp[1]);
        else if (sp[0].equals("scoreboardport")) this.scoreBoardPort = Integer.valueOf(sp[1]);
        else if (sp[0].equals("team")) {
          readTeamAccount(sp[1]);
        } else if (sp[0].equals("judge")) {
          readJudgeAccount(sp[1]);
        } else if (sp[0].equals("problem")) {
          readProblemInfo(sp[1]);
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    config.put("ip", this.ip.getHostAddress());
    config.put("port", Integer.toString(this.port));
    config.put("scoreboard_port", Integer.toString(this.scoreBoardPort));
    config.put("start_time", "0");
    config.put("duration", "300");
    config.put("time_stamp", "0");
    configureManager.addEntry(config);
  }
コード例 #3
0
 private void readJudgeAccount(String pathName) {
   AccountManager accountManager = new AccountManager();
   File file = new File(pathName);
   try (BufferedReader br = new BufferedReader(new FileReader(file))) {
     String line;
     while ((line = br.readLine()) != null) {
       String[] sp = line.split(",");
       this.judges.put(sp[0], new Judge(sp[0], null));
       Map<String, String> judge_account = new HashMap<String, String>();
       judge_account.put("account", sp[0]);
       judge_account.put("password", sp[1]);
       judge_account.put("type", "judge");
       accountManager.addEntry(judge_account);
     }
   } catch (IOException e) {
     e.printStackTrace();
     System.exit(1);
   }
 }