fork download
  1. #!/bin/bash
  2.  
  3. # The script is only for C++ source
  4. # Please use freopen to I/O
  5. # Write down the directory of the test data in file PathFile, "Orz" is defined.
  6. # It can't tell RE from WA, so it's up to you. (if you know how to solve this problem, please tell me, thank you.)
  7. # There must be some grammer errors in these sentence, just ignore it!
  8.  
  9. #Prepare for all Name
  10. PathFile="Orz"
  11. TmpName='jkjkjkjkjkjkjkjkjkjk' #you can change this but you should make sure that there no filename conflict
  12. ProgName=$1
  13. DataDir=`cat ${PathFile}`
  14. TimeLimit=5 #Change this for change time limit (unit : seconds)
  15.  
  16. Suffix=`echo ${ProgName} | sed -e 's/.*\.\(.*$\)/\1/'`
  17. InputName=`sed -n 's/freopen\s*(\s*"\(.*\)"\s*,\s*"r".*$/\1/p' ${1}`
  18. OutputName=`sed -n 's/freopen\s*(\s*"\(.*\)"\s*,\s*"w".*$/\1/p' ${1}`
  19.  
  20. #Compile
  21. Flag_cpp="g++ -o2 ${ProgName} -o ${TmpName} -pg"
  22. Compile_Success=0
  23.  
  24. if [ "${Suffix}" = "cpp" ]; then
  25. $Flag_cpp
  26. if [ "$?" = 0 ] ; then Compile_Success=1; fi
  27. fi
  28.  
  29. #Fail to Compile
  30. if [ "${Compile_Success}" = 0 ]
  31. then
  32. echo "Compile Error"
  33. exit
  34. fi
  35.  
  36. #Test...
  37. Total_Time=0
  38. Total=0
  39. cnt=0
  40. input_list=$(find ${DataDir} -regex '.*\.in[.0-9]*')
  41.  
  42. echo "-------------------------------------------------------------------"
  43. for i in ${input_list}; do
  44. cp ${i} ${InputName}
  45. usetime=`{ time timeout ${TimeLimit} ./${TmpName}; } 2>&1 | grep real | sed 's/real\s//g'`
  46. min=`echo ${usetime} | sed 's/\([^m]*\).*/\1/g'`
  47. sec=`echo ${usetime} | sed 's/.*m\([^s]*\).*/\1/g'`
  48. used_time=`python -c "print int(${min}*60*1000+${sec}*1000)"`
  49.  
  50. #check tle
  51. msLimit=`expr $TimeLimit \* 1000`
  52. if [ $used_time -ge $msLimit ]; then
  53. TLE=1
  54. else
  55. TLE=0
  56. fi
  57.  
  58. for j in {"out","ans","ou"}; do
  59. output_file=`echo ${i} | sed -e "s/\.in/\.${j}/g"`
  60. if [ -e ${output_file} ]; then
  61. if [ "${j#.*}" != "in" ]; then
  62. diff -b ${output_file} ${OutputName} -q > vani_log
  63. if [ $? -eq 0 ]; then Status="Accepted"
  64. else Status="Wrong Answer"
  65. fi
  66. fi
  67. fi
  68. done
  69. let cnt=${cnt}+1
  70.  
  71. if [ $TLE = "1" ]; then
  72. Status="Time Limit Exeeceded"
  73. if [ ${cnt} -le 9 ]; then
  74. echo "Test Case ${cnt} : ${Status} Time: ${used_time} ms"
  75. else
  76. echo "Test Case ${cnt} : ${Status} Time: ${used_time} ms"
  77. fi
  78. else
  79. if [ ${cnt} -le 9 ]; then
  80. echo "Test Case ${cnt} : ${Status} Time: ${used_time} ms"
  81. else
  82. echo "Test Case ${cnt} : ${Status} Time: ${used_time} ms"
  83. fi
  84. fi
  85. if [ "$Status" = "Accepted" ]
  86. then
  87. Total=`expr $Total + 1`
  88. fi
  89. Total_Time=`expr $Total_Time + $used_time`
  90. done
  91.  
  92. if [ -e ${InputName} ]; then
  93. sudo rm ${InputName}
  94. fi
  95. if [ -e ${OutputName} ]; then
  96. sudo rm ${OutputName}
  97. fi
  98. if [ -e ${TmpName} ]; then
  99. sudo rm ${TmpName}
  100. fi
  101.  
  102. echo "-------------------------------------------------------------------"
  103. echo "Total used time: $Total_Time ms"
  104. echo "Total case(s): $cnt"
  105. echo "Accepted case(s): $Total"
  106. echo "Done"
  107.  
Success #stdin #stdout #stderr 0.01s 5300KB
stdin
Standard input is empty
stdout
Compile Error
stderr
cat: Orz: No such file or directory