添加配置:
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
n=5000
g++ -std=c++14 -O2 gen.cpp -o gen
g++ -std=c++14 -O2 std.cpp -o std
g++ -std=c++14 -O2 sol.cpp -o sol
for ((i=1; i<=n; i++)); do
./gen $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 .ans .out > /dev/null; then
echo "Test $i: Wrong answer"
exit 1
fi
if ((i % (n / 10) == 0)); then
echo "Passed $i tests";
fi
done
echo "Accept"