Skip to content

Commit b30eb1a

Browse files
mpsijmmeisterT
authored andcommitted
#2307 Multi-pass: copy feedback dir between passes (but remove nextpass.in)
This commit has been used in NWERC 2024 (d7cc716), as well as GCPC 2025 and BAPC 2025. It follows the latest release-candidate specification of multi-pass validation: https://www.kattis.com/problem-package-format/spec/2025-09.html#multi-pass-validation (the mirror at https://icpc.io/problem-package-format/spec/2025-09.html should be deployed "soon™"). Copying the feedback directory to the next pass is an implementation of "All other files inside the feedback directory are guaranteed to persist between passes." Additionally, "Note that the `nextpass.in` will be removed before the next pass." See also Kattis/problem-package-format#446 (comment)
1 parent 30abfc9 commit b30eb1a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

judge/judgedaemon.main.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,16 @@ function judge(array $judgeTask): bool
14511451
$passdir = $testcasedir . '/' . $passCnt;
14521452
mkdir($passdir, 0755, true);
14531453

1454+
// In multi-pass problems, all files in the feedback directory
1455+
// are guaranteed to persist between passes, except `nextpass.in`.
1456+
// So, we recursively copy the feedback directory for every pass
1457+
// after the first (note that $passCnt starts at 1).
1458+
if ($passCnt > 1) {
1459+
$prevPassdir = $testcasedir . '/' . ($passCnt - 1) . '/feedback';
1460+
system('cp -R ' . dj_escapeshellarg($prevPassdir) . ' ' . dj_escapeshellarg($passdir . '/'));
1461+
system('rm ' . dj_escapeshellarg($passdir . '/feedback/nextpass.in'));
1462+
}
1463+
14541464
// Copy program with all possible additional files to testcase
14551465
// dir. Use hardlinks to preserve space with big executables.
14561466
$programdir = $passdir . '/execdir';

judge/testcase_run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ if [ $COMBINED_RUN_COMPARE -eq 1 ]; then
197197
# A combined run and compare script may now already need the
198198
# feedback directory, and perhaps access to the test answers (but
199199
# only the original that lives outside the chroot).
200-
mkdir feedback
200+
mkdir -p feedback
201201
RUNARGS="$RUNARGS $TESTOUT compare.meta feedback"
202202
fi
203203

@@ -234,8 +234,8 @@ if [ $COMBINED_RUN_COMPARE -eq 0 ]; then
234234

235235
exitcode=0
236236
# Create dir for feedback files and make it writable for $RUNUSER
237-
mkdir feedback
238-
chmod a+w feedback
237+
mkdir -p feedback
238+
chmod -R a+w feedback
239239

240240
runcheck $GAINROOT "$RUNGUARD" ${DEBUG:+-v} $CPUSET_OPT -u "$RUNUSER" -g "$RUNGROUP" \
241241
-m $SCRIPTMEMLIMIT -t $SCRIPTTIMELIMIT --no-core \

0 commit comments

Comments
 (0)