allowed no ouput file

This commit is contained in:
Himit_ZH 2022-01-18 20:51:54 +08:00
parent 99312d8848
commit 7029af9254
3 changed files with 17 additions and 9 deletions

View File

@ -33,7 +33,7 @@
然后压缩测试用例到一个zip中
:::danger
**注意:即使没有输入或者没有输出,也请提供对应的空输入(输出)文件,不要在这些文件外面套多一层文件夹,请直接压缩!!!**
**注意:不要在这些文件外面套多一层文件夹,请直接压缩!!!**
:::
:::info

View File

@ -95,14 +95,14 @@ public class TestCaseController {
// 进行数据对应检查,同时生成返回数据
List<HashMap<String, String>> problemCaseList = new LinkedList<>();
for (String key : inputData.keySet()) {
// 若有名字不对应直接返回失败
// 若有名字对应的out文件不存在的直接生成对应的out文件
if (outputData.getOrDefault(key, null) == null) {
FileUtil.del(fileDir);
return CommonResult.errorResponse("请检查数据压缩包里面的in和out、ans文件是否一一对应");
FileWriter fileWriter = new FileWriter(fileDir + File.separator + key + ".out");
fileWriter.write("");
}
HashMap<String, String> testcaseMap = new HashMap<>();
testcaseMap.put("input", inputData.get(key));
testcaseMap.put("output", outputData.get(key));
testcaseMap.put("output", key + ".out");
problemCaseList.add(testcaseMap);
}

View File

@ -272,6 +272,7 @@ public class ProblemServiceImpl extends ServiceImpl<ProblemMapper, Problem> impl
} else {
newProblemCaseList.add(problemCase.setPid(pid));
}
if (problemCase.getScore() != null) {
sumScore += problemCase.getScore();
}
@ -394,6 +395,10 @@ public class ProblemServiceImpl extends ServiceImpl<ProblemMapper, Problem> impl
if (problemCase.getScore() != null) {
sumScore += problemCase.getScore();
}
if (StringUtils.isEmpty(problemCase.getOutput())) {
String filePreName = problemCase.getInput().split("\\.")[0];
problemCase.setOutput(filePreName + ".out");
}
problemCase.setPid(pid);
}
// 设置oi总分数根据每个测试点的加和
@ -482,13 +487,16 @@ public class ProblemServiceImpl extends ServiceImpl<ProblemMapper, Problem> impl
FileReader inputFile = new FileReader(testCasesDir + File.separator + problemCase.getInput(), CharsetUtil.UTF_8);
String input = inputFile.readString().replaceAll("\r\n", "\n");
FileWriter fileWriter = new FileWriter(testCasesDir + File.separator + problemCase.getInput(), CharsetUtil.UTF_8);
fileWriter.write(input);
FileWriter inputFileWriter = new FileWriter(testCasesDir + File.separator + problemCase.getInput(), CharsetUtil.UTF_8);
inputFileWriter.write(input);
// 读取输出文件
FileReader outputFile = new FileReader(testCasesDir + File.separator + problemCase.getOutput(), CharsetUtil.UTF_8);
String output = outputFile.readString().replaceAll("\r\n", "\n");
FileWriter outFileWriter = new FileWriter(testCasesDir + File.separator + problemCase.getOutput(), CharsetUtil.UTF_8);
outFileWriter.write(output);
// spj和interactive是根据特判程序输出判断结果所以无需初始化测试数据
if (Constants.JudgeMode.DEFAULT.getMode().equals(mode)) {
// 原数据MD5
@ -706,12 +714,12 @@ public class ProblemServiceImpl extends ServiceImpl<ProblemMapper, Problem> impl
importProblemVo.setSamples(problemCaseList);
if (!StringUtils.isEmpty(problem.getUserExtraFile())) {
HashMap<String,String> userExtraFileMap = (HashMap<String, String>) JSONUtil.toBean(problem.getUserExtraFile(), Map.class);
HashMap<String, String> userExtraFileMap = (HashMap<String, String>) JSONUtil.toBean(problem.getUserExtraFile(), Map.class);
importProblemVo.setUserExtraFile(userExtraFileMap);
}
if (!StringUtils.isEmpty(problem.getJudgeExtraFile())) {
HashMap<String,String> judgeExtraFileMap = (HashMap<String, String>) JSONUtil.toBean(problem.getJudgeExtraFile(), Map.class);
HashMap<String, String> judgeExtraFileMap = (HashMap<String, String>) JSONUtil.toBean(problem.getJudgeExtraFile(), Map.class);
importProblemVo.setUserExtraFile(judgeExtraFileMap);
}