bash 一键测样例 + 对拍
一件测样例:
# $1: Problem name
# $2: Whether use sanitizer ot not
# $3: first sample's id
# $4: last sample's id
ulimit -s 512000
if [ $2 == 1 ]; then
g++ -o $1 $1.cpp -std=c++14 -O2 -Wall -fsanitize=address,undefined || exit
else
g++ -o $1 $1.cpp -std=c++14 -O2 -static || exit
fi
echo -e "Compiled successfully\n"
for i in $(seq $3 $4); do
cp $1$i.in $1.in
\time -f $1$i": %es %MKB" ./$1 || exit
diff -Zq $1.out $1$i.ans
done
对拍 in bash
cnt=1
while true; do
./$1_gen
cp $1_good.in $1.in
./$1 || exit
./$1_good || exit
if diff -Zq $1.out $1_good.out; then
echo "$((cnt++)) AC"
else
echo "$cnt WA"
exit
fi
done