mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: checker: fix early eof
This commit is contained in:
1 file changed
+28
-10
@@ -28,7 +28,14 @@ function parseDiffMsg(msg: string) {
|
|||||||
if (!msg) return '';
|
if (!msg) return '';
|
||||||
if (!msg.startsWith('L=')) throw new Error();
|
if (!msg.startsWith('L=')) throw new Error();
|
||||||
const [meta, u, t] = msg.split('\n');
|
const [meta, u, t] = msg.split('\n');
|
||||||
const lineNum = +meta.split('L=')[1];
|
const lline = meta.split('L=')[1];
|
||||||
|
if (lline?.trim() === 'EOF') {
|
||||||
|
const next = u.split('EOF on ')[1].split(' ')[0];
|
||||||
|
if (next === 'usrout.processed') return 'Standard answer longer than user output.';
|
||||||
|
if (next === 'answer.processed') return 'User output longer than standard answer.';
|
||||||
|
return `Unable to parse: ${u}`;
|
||||||
|
}
|
||||||
|
const lineNum = +lline;
|
||||||
// Split by token
|
// Split by token
|
||||||
const usr = u.trim().split(' ');
|
const usr = u.trim().split(' ');
|
||||||
const std = t.trim().split(' ');
|
const std = t.trim().split(' ');
|
||||||
@@ -51,19 +58,30 @@ function parseDiffMsg(msg: string) {
|
|||||||
|
|
||||||
const compareSh = `#!/bin/bash
|
const compareSh = `#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
usrout=usrout
|
|
||||||
answer=answer
|
|
||||||
if [ "$1" = "BZ" ]; then
|
if [ "$1" = "BZ" ]; then
|
||||||
cat $usrout | awk '{sub(/[ \\t]+$/, ""); print $0;}' | awk '/^$/{n=n RS}; /./{printf "%s",n; n=""; print}' >usrout.processed
|
cat usrout | awk '{sub(/[ \\t\\r]+$/, ""); print $0;}' | awk '/^$/{n=n RS}; /./{printf "%s",n; n=""; print}' >usrout.processed
|
||||||
usrout=usrout.processed
|
cat answer | awk '{sub(/[ \\t\\r]+$/, ""); print $0;}' | awk '/^$/{n=n RS}; /./{printf "%s",n; n=""; print}' >answer.processed
|
||||||
cat $answer | awk '{sub(/[ \\t]+$/, ""); print $0;}' | awk '/^$/{n=n RS}; /./{printf "%s",n; n=""; print}' >answer.processed
|
else
|
||||||
answer=answer.processed
|
cat usrout | awk '{sub(/[\\r]+$/, ""); print $0;}' >usrout.processed
|
||||||
|
cat answer | awk '{sub(/[\\r]+$/, ""); print $0;}' >answer.processed
|
||||||
fi
|
fi
|
||||||
linenum=$(cmp $usrout $answer | awk '{print $NF}')
|
usrsize=$(wc -c < usrout.processed)
|
||||||
|
stdsize=$(wc -c < answer.processed)
|
||||||
|
if [ "$usrsize" -gt "$stdsize" ]; then
|
||||||
|
echo " (EOF)${' '.repeat(64)}" >>answer.processed
|
||||||
|
elif [ "$usrsize" -lt "$stdsize" ]; then
|
||||||
|
echo " (EOF)${' '.repeat(64)}" >>usrout.processed
|
||||||
|
fi
|
||||||
|
result=$(cmp usrout.processed answer.processed || true)
|
||||||
|
linenum=$(echo "$result" | awk '{print $NF}')
|
||||||
if [ -n "$linenum" ]; then
|
if [ -n "$linenum" ]; then
|
||||||
echo "L=$linenum"
|
echo "L=$linenum"
|
||||||
awk "NR==$linenum" $usrout
|
awk "NR==$linenum" usrout.processed
|
||||||
awk "NR==$linenum" $answer
|
awk "NR==$linenum" answer.processed
|
||||||
|
elif [ -n "$result" ]; then
|
||||||
|
# cmp: EOF on [filename] which is empty
|
||||||
|
echo "L=EOF"
|
||||||
|
echo "$result"
|
||||||
fi
|
fi
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user