Windows
- 1.cpp
- bruteforce.cpp
- gen_data.cpp
- duipai.cpp:
#include <bits/stdc++.h>
using namespace std;
int main() {
int i = 0;
do {
system("gen_data.exe > in.txt");
system("1.exe < in.txt > out.txt");
system("bruteforce.exe < in.txt > ans.txt");
cout << ++i << endl;
} while (!system("fc out.txt ans.txt"));
return 0;
}MacOS / Linux
- 1.cpp
- bruteforce.cpp
- gen_data.cpp
- duipai.sh:
if ! [ -e $1.cpp ]; then
echo "file doesn't exist"
exit
fi
shopt -s expand_aliases
alias comp_cpp="g++ -O3 -Wall -Wextra -Wshadow -std=c++14"
comp_cpp bruteforce.cpp -o bruteforce.out
comp_cpp $1.cpp -o $1.out
comp_cpp gen_data.cpp -o gen_data
i=0
while true
do
./gen_data > in
./bruteforce.out < in > ans
./$1.out < in > out
diff -b -B ans out > dif
if [ -s ./dif ]; then
echo $i
echo "hack:"
cat in
echo "ans:"
cat ans
echo "out:"
cat out
rm -f $1.out bruteforce.out gen_data dif
exit
else
let i++
echo $i
fi
done用法:sudo chmod a+x duipaish; ./duipai.sh 1