@echo off
for %%i in (..) do set problem_name=%%~ni

echo "[burunduk3]: I didn't test this script. Remove this if it really works, please."
rem "You are also welcome to modify it, of course."

echo "compile..."
g++ -O2 -Wall -o gen.exe gen.cpp
g++ -O2 -Wall -o split.exe split.cpp
g++ -O2 -Wall -I ../../../include -o validate.exe validate.cpp
copy ..\%problem_name%_od.* .\* > nul
g++ -O2 %problem_name%_od.cpp -o %problem_name%_od.exe

echo "generate..."
gen.exe > tests.gen
split.exe tests.manual tests.gen

echo "validate..."
for %%i in (??) do ( 
  validate.exe < %%i 
)

echo "generating answers..."
for %%i in (??) do (
    echo %%i
    copy %%i %problem_name%.in > nul
    %problem_name%_od.exe
    copy %problem_name%.out %%i.a > nul
)

del tests.gen