對拍程式

weixin_34162629發表於2017-07-29

Linux中,新建dp.sh,內容如下:

#!/bin/bash
while true ;do
#   ./gen >in
#   ./bruteforce <in >ans
#   ./my <in >out
#   if diff out ans; then
    ./$1 <$2.in >out
    if diff -b -y --suppress-common-lines out $2.out ; then
        echo AC
    else
        echo WA
        break;
    read p
    fi
    sleep 1
done

執行./dp.sh
gen 是生成資料的程式,bruteforce 是暴力的程式,my 是我要測試的程式。
diff 的引數-b是忽略空格引起的變化,-y是使用並列格式輸出,--suppress-common-lines是在並列格式中不印出公共行。
ps.來源是學長們留下的板子上的,然後我加上了引數。

相關文章