diff --git a/.idea/compiler.xml b/.idea/compiler.xml index cd7d578dcf267f5af2310a119eda659e952d81b4..ec3f74e6d8bb12d24a81e2ebd3ebb47c221664dc 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -2,6 +2,7 @@ <project version="4"> <component name="CompilerConfiguration"> <annotationProcessing> + <profile default="true" name="Default" enabled="true" /> <profile name="Maven default annotation processors profile" enabled="true"> <sourceOutputDir name="target/generated-sources/annotations" /> <sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> diff --git a/src/main/java/org/example/Main.java b/src/main/java/org/example/Main.java index c3726587a241fab27023705716dd44c352b189b0..dca9b913a9d5864b6b522fecdd66665f7b365b0b 100644 --- a/src/main/java/org/example/Main.java +++ b/src/main/java/org/example/Main.java @@ -4,6 +4,7 @@ import org.example.answerSheet.AnswerSheet; import org.example.exam.Exam; import org.example.exam.ExamFactory; import org.example.grader.ExamGrader; +import org.example.grader.judgeStrategy.programmingThreadPool.ProgrammingThreadPool; import java.io.BufferedWriter; import java.io.File; @@ -47,14 +48,17 @@ public class Main { File[] files = answersFolder.listFiles(); if (files != null) { for (File file : files) { - AnswerSheet answerSheet = AnswerSheet.createAnswerSheet(file); - int grade = ExamGrader.grade(exams.get(id2Index.get(answerSheet.getExamId())),answerSheet); - writer.write(String.valueOf(answerSheet.getExamId()) + ',' + - String.valueOf(answerSheet.getStuId()) + ',' + String.valueOf(grade)); - writer.newLine(); + if (file.getName().endsWith("json")) { + AnswerSheet answerSheet = AnswerSheet.createAnswerSheet(file); + int grade = ExamGrader.grade(exams.get(id2Index.get(answerSheet.getExamId())), answerSheet); + writer.write(String.valueOf(answerSheet.getExamId()) + ',' + + String.valueOf(answerSheet.getStuId()) + ',' + String.valueOf(grade)); + writer.newLine(); + } } } } + ProgrammingThreadPool.getInstance().shutdown(); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/org/example/answerSheet/AnswerSheet.java b/src/main/java/org/example/answerSheet/AnswerSheet.java index 4f2a1b8e8d9cc5c5109d4e68ede186e3cd026a03..e9b5867f097be7476e6a688fb4c403621be00882 100644 --- a/src/main/java/org/example/answerSheet/AnswerSheet.java +++ b/src/main/java/org/example/answerSheet/AnswerSheet.java @@ -9,6 +9,8 @@ import org.example.answerSheet.answer.Answer; import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; @Data public class AnswerSheet { @@ -17,14 +19,24 @@ public class AnswerSheet { private long submitTime; private Answer[] answers; public static AnswerSheet createAnswerSheet(File file) { + AnswerSheet answerSheet = null; try { String content = FileUtils.readFileToString(file,"utf-8"); JsonParser jsonParser = new JsonParser(); JsonObject jsonAnswerSheet= (JsonObject) jsonParser.parse(content); - return new Gson().fromJson(jsonAnswerSheet,AnswerSheet.class); + answerSheet = new Gson().fromJson(jsonAnswerSheet,AnswerSheet.class); } catch (IOException e) { e.printStackTrace(); } - return null; + if (answerSheet == null) { + return null; + } + String test; + for (Answer answer : answerSheet.getAnswers()) { + if (answer.getAnswer().startsWith("code-answers")) { + answer.setAnswer(file.getParent() + System.getProperty("file.separator") + answer.getAnswer()); + } + } + return answerSheet; } } diff --git a/src/main/java/org/example/grader/ExamGrader.java b/src/main/java/org/example/grader/ExamGrader.java index 67f7842687e87f2e96185e3559fc36ef14bb9bb5..4b05c2d8b56b9b63caa2bdba0fab6cb0b69a1cd6 100644 --- a/src/main/java/org/example/grader/ExamGrader.java +++ b/src/main/java/org/example/grader/ExamGrader.java @@ -4,7 +4,7 @@ import lombok.Data; import org.example.answerSheet.AnswerSheet; import org.example.answerSheet.answer.Answer; import org.example.exam.Exam; -import org.example.grader.strategy.*; +import org.example.grader.judgeStrategy.*; import org.example.question.MultipleChoiceQuestion; import org.example.question.Question; @@ -17,17 +17,12 @@ public class ExamGrader { int grade = 0; Question[] questions = exam.getQuestions(); Answer[] answers = answerSheet.getAnswers(); - boolean[] answered = new boolean[questions.length]; - for (int i = 0;i < questions.length;i++) { - answered[i] = false; - } QuestionGrader questionGrader = new QuestionGrader(SingleChoiceStrategy.getInstance()); for (int i = 0;i < answers.length;i++) { Answer answer = answers[i]; String stuAnswer = answer.getAnswer(); Question question = questions[answer.getId() - 1]; - answered[answer.getId() - 1] = true; switch (question.getType()) { case 1: questionGrader.setJudgeStrategy(SingleChoiceStrategy.getInstance()); @@ -55,11 +50,6 @@ public class ExamGrader { } grade += questionGrader.performCalculateScore(question,answer); } - for (int i = 0;i < questions.length;i++) { - if (!answered[i] && questions[i].getType() == 3) { - grade += questions[i].getPoints(); - } - } return grade; } } diff --git a/src/main/java/org/example/grader/QuestionGrader.java b/src/main/java/org/example/grader/QuestionGrader.java index 2ae995ba4d9b911b7f77475251da3110e22de61b..747424e47a96acb87d6c0956775c13f357fc4510 100644 --- a/src/main/java/org/example/grader/QuestionGrader.java +++ b/src/main/java/org/example/grader/QuestionGrader.java @@ -2,7 +2,7 @@ package org.example.grader; import lombok.Data; import org.example.answerSheet.answer.Answer; -import org.example.grader.strategy.JudgeStrategy; +import org.example.grader.judgeStrategy.JudgeStrategy; import org.example.question.Question; @Data diff --git a/src/main/java/org/example/grader/strategy/FixStrategy.java b/src/main/java/org/example/grader/judgeStrategy/FixStrategy.java similarity index 96% rename from src/main/java/org/example/grader/strategy/FixStrategy.java rename to src/main/java/org/example/grader/judgeStrategy/FixStrategy.java index 43f86abbbebb889a56a0dda42951b8662d636f9b..f776df9ad7c67050cd423cc1a707d6818a95eabe 100644 --- a/src/main/java/org/example/grader/strategy/FixStrategy.java +++ b/src/main/java/org/example/grader/judgeStrategy/FixStrategy.java @@ -1,4 +1,4 @@ -package org.example.grader.strategy; +package org.example.grader.judgeStrategy; import org.example.answerSheet.answer.Answer; import org.example.question.MultipleChoiceQuestion; diff --git a/src/main/java/org/example/grader/strategy/JudgeStrategy.java b/src/main/java/org/example/grader/judgeStrategy/JudgeStrategy.java similarity index 80% rename from src/main/java/org/example/grader/strategy/JudgeStrategy.java rename to src/main/java/org/example/grader/judgeStrategy/JudgeStrategy.java index d01306dd234b90709fefeab1cd702ab14e0ca272..578f88ad44487e42986499eb572af9277dd9594a 100644 --- a/src/main/java/org/example/grader/strategy/JudgeStrategy.java +++ b/src/main/java/org/example/grader/judgeStrategy/JudgeStrategy.java @@ -1,4 +1,4 @@ -package org.example.grader.strategy; +package org.example.grader.judgeStrategy; import org.example.answerSheet.answer.Answer; import org.example.question.Question; diff --git a/src/main/java/org/example/grader/strategy/NothingStrategy.java b/src/main/java/org/example/grader/judgeStrategy/NothingStrategy.java similarity index 95% rename from src/main/java/org/example/grader/strategy/NothingStrategy.java rename to src/main/java/org/example/grader/judgeStrategy/NothingStrategy.java index f42387b8422d3d1a723ce4673814a2b117a9d223..74f0627aef26600cd5e63d6e0220fb2b4dd41347 100644 --- a/src/main/java/org/example/grader/strategy/NothingStrategy.java +++ b/src/main/java/org/example/grader/judgeStrategy/NothingStrategy.java @@ -1,4 +1,4 @@ -package org.example.grader.strategy; +package org.example.grader.judgeStrategy; import org.example.answerSheet.answer.Answer; import org.example.question.MultipleChoiceQuestion; diff --git a/src/main/java/org/example/grader/strategy/PartialStrategy.java b/src/main/java/org/example/grader/judgeStrategy/PartialStrategy.java similarity index 97% rename from src/main/java/org/example/grader/strategy/PartialStrategy.java rename to src/main/java/org/example/grader/judgeStrategy/PartialStrategy.java index 6a42e33b89e588223ab70d82960640488ae8def4..3a0c7b725dbfa467e3c83a2caf811e8682e38c64 100644 --- a/src/main/java/org/example/grader/strategy/PartialStrategy.java +++ b/src/main/java/org/example/grader/judgeStrategy/PartialStrategy.java @@ -1,4 +1,4 @@ -package org.example.grader.strategy; +package org.example.grader.judgeStrategy; import org.example.answerSheet.answer.Answer; import org.example.question.MultipleChoiceQuestion; diff --git a/src/main/java/org/example/grader/judgeStrategy/ProgrammingStrategy.java b/src/main/java/org/example/grader/judgeStrategy/ProgrammingStrategy.java new file mode 100644 index 0000000000000000000000000000000000000000..4fd3bbf58124081d5a5eb2846fd19e2b90bbcff0 --- /dev/null +++ b/src/main/java/org/example/grader/judgeStrategy/ProgrammingStrategy.java @@ -0,0 +1,70 @@ +package org.example.grader.judgeStrategy; + +import org.example.answerSheet.answer.Answer; +import org.example.grader.judgeStrategy.executeStrategy.ExecuteStrategy; +import org.example.grader.judgeStrategy.executeStrategy.JavaExecuteStrategy; +import org.example.question.ProgrammingQuestion; +import org.example.question.Question; +import org.example.grader.judgeStrategy.preProcessStrategy.*; +import org.example.grader.judgeStrategy.programmingThreadPool.ProgrammingThreadPool; +import org.example.question.sample.Sample; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.*; + +public class ProgrammingStrategy implements JudgeStrategy{ + private PreProcessStrategy preProcessStrategy; + private ExecuteStrategy executeStrategy; + + private static final ProgrammingStrategy instance = new ProgrammingStrategy(); + + private ProgrammingStrategy() {} + + public static ProgrammingStrategy getInstance() { + return instance; + } + + @Override + public int calculateScore(Question question, Answer answer) { + ProgrammingThreadPool programmingThreadPool = ProgrammingThreadPool.getInstance(); + if (answer.getAnswer().endsWith("java")) { + preProcessStrategy = new JavaPreProcessStrategy(); + executeStrategy = new JavaExecuteStrategy(); + } + Future<Boolean> compileStatus = programmingThreadPool.submit(() -> preProcessStrategy.preProcess(answer.getAnswer())); + try { + if (!compileStatus.get()) { + return 0; // 缂栬瘧澶辫触锛岀洿鎺ヨ繑鍥�0鍒� + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + + String fileName = answer.getAnswer().substring(answer.getAnswer().lastIndexOf('/') + 1); + fileName = fileName.substring(0, fileName.lastIndexOf('.')); + Sample[] samples = ((ProgrammingQuestion) question).getSamples(); + + List<Future<Boolean>> futures = new ArrayList<>(); + + // 鎻愪氦鎵€鏈夋墽琛屼换鍔″埌绾跨▼姹� + for (Sample sample : samples) { + String finalFileName = fileName; + Callable<Boolean> task = () -> executeStrategy.execute(finalFileName, sample); + futures.add(programmingThreadPool.submit(task)); + } + + // 妫€鏌ユ墍鏈変换鍔$殑鎵ц缁撴灉 + for (Future<Boolean> future : futures) { + try { + // 濡傛灉鏈変换浣曚竴涓牱渚嬫墽琛屼笉閫氳繃锛岃繑鍥�0鍒� + if (!future.get()) { + return 0; + } + } catch (Exception e) { + return 0; + } + } + return question.getPoints(); // 杩斿洖婊″垎 + } +} diff --git a/src/main/java/org/example/grader/strategy/SingleChoiceStrategy.java b/src/main/java/org/example/grader/judgeStrategy/SingleChoiceStrategy.java similarity index 94% rename from src/main/java/org/example/grader/strategy/SingleChoiceStrategy.java rename to src/main/java/org/example/grader/judgeStrategy/SingleChoiceStrategy.java index 2987d674b6fcb5a000a19fb6b29463635f096985..dae02e53ffc5343e20e51926c55486ebf696edf2 100644 --- a/src/main/java/org/example/grader/strategy/SingleChoiceStrategy.java +++ b/src/main/java/org/example/grader/judgeStrategy/SingleChoiceStrategy.java @@ -1,4 +1,4 @@ -package org.example.grader.strategy; +package org.example.grader.judgeStrategy; import org.example.answerSheet.answer.Answer; import org.example.question.Question; diff --git a/src/main/java/org/example/grader/judgeStrategy/executeStrategy/ExecuteStrategy.java b/src/main/java/org/example/grader/judgeStrategy/executeStrategy/ExecuteStrategy.java new file mode 100644 index 0000000000000000000000000000000000000000..792e9d43e0e630702cfb296eafb650fc29c78f7a --- /dev/null +++ b/src/main/java/org/example/grader/judgeStrategy/executeStrategy/ExecuteStrategy.java @@ -0,0 +1,7 @@ +package org.example.grader.judgeStrategy.executeStrategy; + +import org.example.question.sample.Sample; + +public interface ExecuteStrategy { + boolean execute(String fileName, Sample sample); +} diff --git a/src/main/java/org/example/grader/judgeStrategy/executeStrategy/JavaExecuteStrategy.java b/src/main/java/org/example/grader/judgeStrategy/executeStrategy/JavaExecuteStrategy.java new file mode 100644 index 0000000000000000000000000000000000000000..ca296f329859a8202b98bb17abf532201cc5cc3e --- /dev/null +++ b/src/main/java/org/example/grader/judgeStrategy/executeStrategy/JavaExecuteStrategy.java @@ -0,0 +1,48 @@ +package org.example.grader.judgeStrategy.executeStrategy; + +import org.example.question.sample.Sample; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URISyntaxException; +import java.nio.file.Paths; + +public class JavaExecuteStrategy implements ExecuteStrategy{ + @Override + public boolean execute(String fileName, Sample sample) { + String classpath = ""; + try { + classpath = Paths.get(getClass().getClassLoader().getResource("cases").toURI()).toString() + + System.getProperty("file.separator") + "compileResult"; + } catch (URISyntaxException e) { + e.printStackTrace(); + } + Process runProcess; + try { + String command = "java -cp " + classpath + " " + fileName + " " + sample.getInput(); + // 璁剧疆classpath锛屽苟鎵ц鎸囧畾鐨勭被 + runProcess = Runtime.getRuntime().exec(command); + BufferedReader inputReader = new BufferedReader(new InputStreamReader(runProcess.getInputStream())); + String output = ""; + String line; + while ((line = inputReader.readLine()) != null) { + output += line; + } + inputReader.close(); + + // 妫€鏌ョ▼搴忔槸鍚﹀紓甯搁€€鍑� + int exitVal = runProcess.waitFor(); + if (exitVal == 0) { + if (!output.equals(sample.getOutput())) { + return false; + } + } else { + return false; + } + } catch (IOException | InterruptedException e) { + return false; + } + return true; + } +} diff --git a/src/main/java/org/example/grader/judgeStrategy/preProcessStrategy/JavaPreProcessStrategy.java b/src/main/java/org/example/grader/judgeStrategy/preProcessStrategy/JavaPreProcessStrategy.java new file mode 100644 index 0000000000000000000000000000000000000000..80b2e8852519ffaf5f69b5260b1c631071f55c08 --- /dev/null +++ b/src/main/java/org/example/grader/judgeStrategy/preProcessStrategy/JavaPreProcessStrategy.java @@ -0,0 +1,25 @@ +package org.example.grader.judgeStrategy.preProcessStrategy; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Paths; + +public class JavaPreProcessStrategy implements PreProcessStrategy { + @Override + public boolean preProcess(String filePath) { + Process compileProcess; + try { + // 浣跨敤-d閫夐」鎸囧畾缂栬瘧鍚庣殑杈撳嚭鐩綍 + compileProcess = Runtime.getRuntime().exec("javac -d " + + Paths.get(getClass().getClassLoader().getResource("cases").toURI()).toString() + + System.getProperty("file.separator") + "compileResult " + filePath); + compileProcess.waitFor(); + if (compileProcess.exitValue() == 0) { + return true; + } + } catch (IOException | InterruptedException | URISyntaxException e) { + e.printStackTrace(); + } + return false; + } +} diff --git a/src/main/java/org/example/grader/judgeStrategy/preProcessStrategy/PreProcessStrategy.java b/src/main/java/org/example/grader/judgeStrategy/preProcessStrategy/PreProcessStrategy.java new file mode 100644 index 0000000000000000000000000000000000000000..e90d1437b57b3deccd6f4a8a967c1c85da886b48 --- /dev/null +++ b/src/main/java/org/example/grader/judgeStrategy/preProcessStrategy/PreProcessStrategy.java @@ -0,0 +1,5 @@ +package org.example.grader.judgeStrategy.preProcessStrategy; + +public interface PreProcessStrategy { + boolean preProcess(String filePath); +} \ No newline at end of file diff --git a/src/main/java/org/example/grader/judgeStrategy/programmingThreadPool/ProgrammingThreadPool.java b/src/main/java/org/example/grader/judgeStrategy/programmingThreadPool/ProgrammingThreadPool.java new file mode 100644 index 0000000000000000000000000000000000000000..3e53ba25ba093ed8a3fb78c398199ea28ef7c6f2 --- /dev/null +++ b/src/main/java/org/example/grader/judgeStrategy/programmingThreadPool/ProgrammingThreadPool.java @@ -0,0 +1,59 @@ +package org.example.grader.judgeStrategy.programmingThreadPool; + +import java.util.concurrent.*; +import java.util.List; +import java.util.ArrayList; + +public class ProgrammingThreadPool { + private final List<Thread> threads; + private final BlockingQueue<Runnable> queue; + + private final static ProgrammingThreadPool instance = new ProgrammingThreadPool(5); + + public static ProgrammingThreadPool getInstance() { + return instance; + } + + public ProgrammingThreadPool(int numberOfThreads) { + queue = new LinkedBlockingQueue<>(); + threads = new ArrayList<>(); + for (int i = 0; i < numberOfThreads; i++) { + Thread thread = new Thread(this::run); + thread.start(); + threads.add(thread); + } + } + + private void run() { + while (true) { + try { + Runnable task = null; + synchronized (queue) { + if (!queue.isEmpty()) { + task = queue.poll(); + } else { + queue.wait(); + } + } + if (task != null) { + task.run(); + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + } + + public <V> Future<V> submit(Callable<V> callable) { + FutureTask<V> task = new FutureTask<>(callable); + synchronized (queue) { + queue.add(task); + queue.notify(); + } + return task; + } + + public void shutdown() { + threads.forEach(Thread::stop); + } +} diff --git a/src/main/java/org/example/grader/strategy/ProgrammingStrategy.java b/src/main/java/org/example/grader/strategy/ProgrammingStrategy.java deleted file mode 100644 index 6cd2d66ca4e8da7e96a37cf8fdec958bceb01fe0..0000000000000000000000000000000000000000 --- a/src/main/java/org/example/grader/strategy/ProgrammingStrategy.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.example.grader.strategy; - -import org.example.answerSheet.answer.Answer; -import org.example.question.Question; - -public class ProgrammingStrategy implements JudgeStrategy{ - private static final ProgrammingStrategy instance = new ProgrammingStrategy(); - - private ProgrammingStrategy() {} - - public static ProgrammingStrategy getInstance() { - return instance; - } - - @Override - public int calculateScore(Question question, Answer answer) { - return question.getPoints(); - } -} diff --git a/src/test/resources/cases/answers/1-1.json b/src/test/resources/cases/answers/1-1.json index 9c64875c01733f65912b8f5e3f69745b6679ab71..bdc86a4953ecf84a0510077a1ced926ca144d977 100644 --- a/src/test/resources/cases/answers/1-1.json +++ b/src/test/resources/cases/answers/1-1.json @@ -13,7 +13,7 @@ }, { "id": 3, - "answer": "code" + "answer": "code-answers/Solution11.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/answers/1-2.json b/src/test/resources/cases/answers/1-2.json index f6b0c9fdc3c59bea2c2c038b5e72b7b70052d4ba..fbb0ee5091f91f639bbff4a1cb215be812589634 100644 --- a/src/test/resources/cases/answers/1-2.json +++ b/src/test/resources/cases/answers/1-2.json @@ -13,7 +13,7 @@ }, { "id": 3, - "answer": "code" + "answer": "code-answers/Solution12.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/answers/1-3.json b/src/test/resources/cases/answers/1-3.json index abe9b300269febaa4b74f781312e5bf9aa5890b7..89674e5d074ce28f0995eb248d36ed456b449b6a 100644 --- a/src/test/resources/cases/answers/1-3.json +++ b/src/test/resources/cases/answers/1-3.json @@ -13,7 +13,7 @@ }, { "id": 3, - "answer": "code" + "answer": "code-answers/Solution13.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/answers/2-1.json b/src/test/resources/cases/answers/2-1.json index 0814d421236455d83d0d6871393019b1bc1ce1c4..989de59b5b5ae5078f008d2e2fafcabc0cc82ccc 100644 --- a/src/test/resources/cases/answers/2-1.json +++ b/src/test/resources/cases/answers/2-1.json @@ -13,7 +13,7 @@ }, { "id": 3, - "answer": "code" + "answer": "code-answers/Solution21.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/answers/2-2.json b/src/test/resources/cases/answers/2-2.json index 02fb7ef6861ecb2aa904a1c7ecff90057bc8f80a..abad12a80841cc45bea67c509dc289d4bae3686b 100644 --- a/src/test/resources/cases/answers/2-2.json +++ b/src/test/resources/cases/answers/2-2.json @@ -13,7 +13,7 @@ }, { "id": 3, - "answer": "code" + "answer": "code-answers/Solution22.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/answers/2-3.json b/src/test/resources/cases/answers/2-3.json index 4833dc6045692468be0f543621943e1b3836bee6..1d2f2fa935a2381456368fd90db81f9d3e241baa 100644 --- a/src/test/resources/cases/answers/2-3.json +++ b/src/test/resources/cases/answers/2-3.json @@ -13,7 +13,7 @@ }, { "id": 3, - "answer": "code" + "answer": "code-answers/Solution23.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/answers/3-1.json b/src/test/resources/cases/answers/3-1.json index 85c1054a06def31dd403954d4178a6434e7170e8..5ea95822964d946ecdc7ba1fd9d39c17b9f102d2 100644 --- a/src/test/resources/cases/answers/3-1.json +++ b/src/test/resources/cases/answers/3-1.json @@ -13,7 +13,7 @@ }, { "id": 3, - "answer": "code" + "answer": "code-answers/Solution31.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/answers/3-2.json b/src/test/resources/cases/answers/3-2.json index 98d3832b8135f5e3568a4bb07ab304637b796ac8..dcfc2c77f08d22fbdd503e531ba77599b3156d5e 100644 --- a/src/test/resources/cases/answers/3-2.json +++ b/src/test/resources/cases/answers/3-2.json @@ -10,6 +10,10 @@ { "id": 2, "answer": "ABD" + }, + { + "id": 3, + "answer": "code-answers/Solution32.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/answers/3-3.json b/src/test/resources/cases/answers/3-3.json index 70535e5eecc771d3c6ea49d5bf5d08e47e98e8c0..72a3c32215d8187f1da74e8de630417788154033 100644 --- a/src/test/resources/cases/answers/3-3.json +++ b/src/test/resources/cases/answers/3-3.json @@ -10,6 +10,10 @@ { "id": 2, "answer": "ABCD" + }, + { + "id": 3, + "answer": "code-answers/Solution33.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/answers/4-1.json b/src/test/resources/cases/answers/4-1.json index d265f5e5577b206030941f8d0216c8a25685f4fc..c2eeb7c942be6f48b854a2f12b82080436cf745f 100644 --- a/src/test/resources/cases/answers/4-1.json +++ b/src/test/resources/cases/answers/4-1.json @@ -13,7 +13,7 @@ }, { "id": 3, - "answer": "code" + "answer": "code-answers/Solution41.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/answers/4-2.json b/src/test/resources/cases/answers/4-2.json index 843ea9ea2dd9b39e53007453331c49a8fcad0c29..27849cb81f77b6e3c567dc7079fdf53ede203f2f 100644 --- a/src/test/resources/cases/answers/4-2.json +++ b/src/test/resources/cases/answers/4-2.json @@ -13,7 +13,7 @@ }, { "id": 3, - "answer": "code" + "answer": "code-answers/Solution42.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/answers/4-3.json b/src/test/resources/cases/answers/4-3.json index dbb837435df5900146ac4ea8a8b25d4e6b681986..0f7dac2ddf3b084c5ea5af7de6c7b3a5a9fa3a1a 100644 --- a/src/test/resources/cases/answers/4-3.json +++ b/src/test/resources/cases/answers/4-3.json @@ -13,7 +13,7 @@ }, { "id": 3, - "answer": "code" + "answer": "code-answers/Solution43.java" } ] } \ No newline at end of file diff --git a/src/test/resources/cases/exams/1.json b/src/test/resources/cases/exams/1.json index 1eddb7d8b928b35754f74d522188c623d8b43c4e..9db34a68a349f950b483d4bb5edfd6df9813441b 100644 --- a/src/test/resources/cases/exams/1.json +++ b/src/test/resources/cases/exams/1.json @@ -42,12 +42,52 @@ "question": "缁欏嚭涓や釜鏁存暟a鍜宐, 姹備粬浠殑鍜屽苟浠ユ暣鏁帮紙int锛夌殑褰㈠紡杩斿洖銆�", "samples": [ { - "input": "1 2", - "output": "3" + "input": "1 3", + "output": "4" }, { "input": "3 4", "output": "7" + }, + { + "input": "1 4", + "output": "5" + }, + { + "input": "3 5", + "output": "8" + }, + { + "input": "1 9", + "output": "10" + }, + { + "input": "3 10", + "output": "13" + }, + { + "input": "1 20", + "output": "21" + }, + { + "input": "3 40", + "output": "43" + }, + { + "input": "1 21", + "output": "22" + }, + { + "input": "3 41", + "output": "44" + }, + { + "input": "1 22", + "output": "23" + }, + { + "input": "3 42", + "output": "45" } ], "timeLimit": 1000, diff --git a/src/test/resources/cases/exams/2.xml b/src/test/resources/cases/exams/2.xml index b0d01abb9488ed7677d5f46d2338154edb92a13a..deb2be9ed077d114acaef31246e67e62c38cc7cb 100644 --- a/src/test/resources/cases/exams/2.xml +++ b/src/test/resources/cases/exams/2.xml @@ -54,6 +54,46 @@ <input>3 4</input> <output>7</output> </sample> + <sample> + <input>1 21</input> + <output>22</output> + </sample> + <sample> + <input>3 14</input> + <output>17</output> + </sample> + <sample> + <input>1 22</input> + <output>23</output> + </sample> + <sample> + <input>3 24</input> + <output>27</output> + </sample> + <sample> + <input>1 32</input> + <output>33</output> + </sample> + <sample> + <input>3 34</input> + <output>37</output> + </sample> + <sample> + <input>1 42</input> + <output>43</output> + </sample> + <sample> + <input>3 54</input> + <output>57</output> + </sample> + <sample> + <input>1 62</input> + <output>63</output> + </sample> + <sample> + <input>3 64</input> + <output>67</output> + </sample> </samples> <timeLimit>1000</timeLimit> <points>70</points> diff --git a/src/test/resources/cases/exams/3.json b/src/test/resources/cases/exams/3.json index 623d5b5d53b098a21a782baf4c9d963e4b54dbb3..f0eabf167c7a6a3dee8b3b290db76dcaf0f43243 100644 --- a/src/test/resources/cases/exams/3.json +++ b/src/test/resources/cases/exams/3.json @@ -41,12 +41,52 @@ "question": "缁欏嚭涓や釜鏁存暟a鍜宐, 姹備粬浠殑鍜屽苟浠ユ暣鏁帮紙int锛夌殑褰㈠紡杩斿洖銆�", "samples": [ { - "input": "1 2", - "output": "3" + "input": "1 3", + "output": "4" }, { "input": "3 4", "output": "7" + }, + { + "input": "1 4", + "output": "5" + }, + { + "input": "3 5", + "output": "8" + }, + { + "input": "1 9", + "output": "10" + }, + { + "input": "3 10", + "output": "13" + }, + { + "input": "1 20", + "output": "21" + }, + { + "input": "3 40", + "output": "43" + }, + { + "input": "1 21", + "output": "22" + }, + { + "input": "3 41", + "output": "44" + }, + { + "input": "1 22", + "output": "23" + }, + { + "input": "3 42", + "output": "45" } ], "timeLimit": 1000, diff --git a/src/test/resources/cases/exams/4.xml b/src/test/resources/cases/exams/4.xml index 6b99a9f0a2d05025f77a2c747b2064e8d7431eff..5523e5e24023a9708072d607236d656c98cb9417 100644 --- a/src/test/resources/cases/exams/4.xml +++ b/src/test/resources/cases/exams/4.xml @@ -49,6 +49,46 @@ <input>3 4</input> <output>7</output> </sample> + <sample> + <input>1 21</input> + <output>22</output> + </sample> + <sample> + <input>3 14</input> + <output>17</output> + </sample> + <sample> + <input>1 22</input> + <output>23</output> + </sample> + <sample> + <input>3 24</input> + <output>27</output> + </sample> + <sample> + <input>1 32</input> + <output>33</output> + </sample> + <sample> + <input>3 34</input> + <output>37</output> + </sample> + <sample> + <input>1 42</input> + <output>43</output> + </sample> + <sample> + <input>3 54</input> + <output>57</output> + </sample> + <sample> + <input>1 62</input> + <output>63</output> + </sample> + <sample> + <input>3 64</input> + <output>67</output> + </sample> </samples> <timeLimit>1000</timeLimit> <points>70</points> diff --git a/src/test/resources/cases/output/expected.csv b/src/test/resources/cases/output/expected.csv index eb8477a72e08730abe794e436c564eecf275bcd6..af75866f88b055ae46a5576aba5ebb13ce11fa12 100644 --- a/src/test/resources/cases/output/expected.csv +++ b/src/test/resources/cases/output/expected.csv @@ -4,10 +4,10 @@ examId, stuId, score 1,3,0 2,1,95 2,2,70 -2,3,90 -3,1,100 -3,2,90 -3,3,70 -4,1,70 -4,2,80 -4,3,90 +2,3,20 +3,1,30 +3,2,20 +3,3,0 +4,1,0 +4,2,10 +4,3,20