添加配置:
cat >> ~/.bashrc << 'EOF'
c() { g++ -std=c++14 -O2 -Wall -Wextra -Wshadow "$1" -o "${1%.cpp}" && ./"${1%.cpp}"; }
d() { g++ -std=c++14 -O1 -Wall -Wextra -Wshadow -fsanitize=address,undefined "$1" -o "${1%.cpp} && ./"${1%.cpp}"; }
EOF
source ~/.bashrc
export -f c d查看函数:
type c d查看配置:
nl -ba ~/.bashrc备份配置:
cp ~/.bashrc ~/.bashrc.bak删除配置:
sed -i "119,120d" ~/.bashrc
unset -f c d授权:
chmod +x stress.sh自动对拍脚本:
set -e
c generator.cpp
c std.cpp
c sol.cpp
for ((i=1; i<=100000; i++)); do
./generator "$i"
if ! timeout 2s ./std; then
echo "Test $i: std RE/TLE!"
exit 1
fi
if ! timeout 2s ./sol; then
echo "Test $i: sol RE/TLE!"
exit 1
fi
if ! diff -w -q .ans .out > /dev/null; then
echo "Test $i: Wrong Answer!"
exit 1
fi
done
echo "Accpet!"