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);
    }
  }
  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);
  }
  public void rejudgeProblem(String problemID) {
    SubmissionManager submissionManager = new SubmissionManager();

    for (Map<String, String> ent : submissionManager.rejudge(problemID)) {
      try {
        ProblemManager problemManager = new ProblemManager();
        Map<String, String> pb = problemManager.getProblemById(problemID);
        JSONObject msg = new JSONObject();
        msg.put("msg_type", "submit");
        msg.put("submission_id", ent.get("submission_id"));
        msg.put("problem_id", ent.get("problem_id"));
        msg.put("language", ent.get("language"));
        msg.put("source_code", ent.get("source_code"));
        msg.put("time_stamp", ent.get("submission_time_stamp"));
        msg.put("testdata_time_stamp", pb.get("time_stamp"));
        Core.getInstance().getScheduler().add(msg);
      } catch (JSONException e) {
        e.printStackTrace();
      }
    }
  }
  public void updateTestData(String problemID, File input, File output, File specialJudge) {
    try {
      int timeStamp = this.getTimer().getCountedTime();
      Map<String, String> entry = new HashMap<>();
      entry.put("problem_id", problemID);
      entry.put("input", MyUtil.readFromFile(input));
      entry.put("output", MyUtil.readFromFile(output));
      if (specialJudge != null) {
        entry.put("special_judge", MyUtil.readFromFile(specialJudge));
      }
      entry.put("time_stamp", Long.toString(timeStamp));
      ProblemManager problemManager = new ProblemManager();
      problemManager.updateEntry(entry);

      ProblemInfo problemInfo = this.problems.get(problemID);
      if (problemInfo != null)
        problemInfo.updateInfo(
            problemInfo.getTimeLimit(), problemInfo.getMemoryLimit(), timeStamp, "", "", "");
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
  }