From 8d4a34aa10b2d6954a1e99d780b4fdeb563ba7a4 Mon Sep 17 00:00:00 2001 From: lzkk <956449176@qq.com> Date: Thu, 28 May 2026 15:27:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(scripts):=20=E4=BF=AE=E5=A4=8D=20score.sh?= =?UTF-8?q?=20=E8=BE=93=E5=87=BA=E5=AF=B9=E6=AF=94=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E2=80=94=E2=80=94=E9=80=82=E9=85=8D=20SysY=20=E9=9D=9E?= =?UTF-8?q?=E9=9B=B6=E8=BF=94=E5=9B=9E=E5=80=BC=20+=20.out=20=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除错误的 exit_code==0 检查(SysY 可返回任意值) - 修复 .out 格式生成:stdout 为空时不插入多余空行 - 修复 ref_time 不记录非零退出码的 bug - functional: 100/100 AC, performance: 57/60 AC --- scripts/score.sh | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/scripts/score.sh b/scripts/score.sh index c5ab8022..70405310 100755 --- a/scripts/score.sh +++ b/scripts/score.sh @@ -168,10 +168,8 @@ run_one() { timeout "$TIMEOUT_SEC" "$QEMU" $QEMU_FLAGS "$ref_exe" > "$ref_out" 2>/dev/null || ref_exit=$? fi ref_end="$(date +%s%3N)" - if [[ $ref_exit -eq 0 ]]; then - ref_time=$((ref_end - ref_start)) - ref_ok=1 - fi + ref_time=$((ref_end - ref_start)) + ref_ok=1 fi fi if [[ $ref_time -lt 1 ]]; then ref_time=1; fi @@ -230,15 +228,20 @@ run_with_args() { end_ns="$(date +%s%3N)" our_time=$((end_ns - start_ns)) [[ $our_time -lt 1 ]] && our_time=1 - if [[ $exit_code -eq 0 ]]; then - if [[ -f "$out_file" ]]; then - # .out 文件格式: stdout + 换行 + 退出码 (与 2026test.sh 一致) - local our_actual="$work_dir/our.actual.out" - { cat "$our_out"; printf '\n'; echo "$exit_code"; } > "$our_actual" - diff -q "$our_actual" "$out_file" >/dev/null 2>&1 && our_correct=1 - else - our_correct=1 + # SysY 程序可返回任意值,不能用 exit_code==0 判断正确性 + # .out 文件格式(与 2026test.sh 一致): stdout + [换行] + 退出码 + local our_actual="$work_dir/our.actual.out" + { + cat "$our_out" + if [[ -s "$our_out" ]] && (( $(tail -c 1 "$our_out" | wc -l) == 0 )); then + printf '\n' fi + echo "$exit_code" + } > "$our_actual" + if [[ -f "$out_file" ]]; then + diff -q "$our_actual" "$out_file" >/dev/null 2>&1 && our_correct=1 + else + our_correct=1 fi fi fi @@ -256,7 +259,7 @@ run_with_args() { timeout "$TIMEOUT_SEC" "$QEMU" $QEMU_FLAGS "$ref_exe" > "$ref_out" 2>/dev/null || ref_exit=$? fi ref_end="$(date +%s%3N)" - [[ $ref_exit -eq 0 ]] && ref_time=$((ref_end - ref_start)) + ref_time=$((ref_end - ref_start)) fi fi [[ $ref_time -lt 1 ]] && ref_time=1