#!/bin/bash

echo "Usage: 'gen_ans_cpp.sh' or 'gen_ans_cpp.sh docheck'"
echo "Generate answers"

source ./include.sh

prob=subset
sol=../solutions/subset_sk_n2logn_rational
ext=cpp
testdir=.

echo "problem = $prob"
echo "solution = $sol.$ext"

compile_cpp $sol.$ext sol.exe

if [[ $1 == "docheck" ]] ; then
  compile_cpp ../check.cpp check.exe
fi

for i in `ls -v $testdir/?? $testdir/???` ; do
  echo "Test $i"
  cp $i $prob.in
  time ./sol.exe || exit
  cp $prob.out $i.a
  if [[ $1 == "docheck" ]] ; then
    ./check.exe $i $i.a $i.a || exit 1
  fi
done

rm $prob.{in,out}
