diff --git a/atcoder/042/scripts/debug.sh b/atcoder/042/scripts/debug.sh deleted file mode 100644 index 1e63f37..0000000 --- a/atcoder/042/scripts/debug.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -DBG_BIN="${BASE}.debug" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -DBG_BIN="build/$DBG_BIN" - -compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT" true -exit $? diff --git a/atcoder/042/scripts/run.sh b/atcoder/042/scripts/run.sh deleted file mode 100644 index ab9aa7d..0000000 --- a/atcoder/042/scripts/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -RUN_BIN="${BASE}.run" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -RUN_BIN="build/$RUN_BIN" - -compile_source "$SRC" "$RUN_BIN" "$OUTPUT" "" -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/atcoder/042/scripts/utils.sh b/atcoder/042/scripts/utils.sh deleted file mode 100644 index e4cf8f8..0000000 --- a/atcoder/042/scripts/utils.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh - -execute_binary() { - binary="$1" - input="$2" - output="$3" - is_debug="$4" - - start=$(date '+%s.%N') - if [ -n "$is_debug" ]; then - asan="$(ldconfig -p | grep libasan.so | head -n1 | awk '{print $4}')" - LD_PRELOAD="$asan" timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - else - timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - fi - CODE=$? - end=$(date '+%s.%N') - truncate -s "$(head -n 1000 "$output" | wc -c)" "$output" - - if [ $CODE -ge 124 ]; then - MSG='' - case $CODE in - 124) MSG='TIMEOUT' ;; - 128) MSG='SIGILL' ;; - 130) MSG='SIGABRT' ;; - 131) MSG='SIGBUS' ;; - 136) MSG='SIGFPE' ;; - 135) MSG='SIGSEGV' ;; - 137) MSG='SIGPIPE' ;; - 139) MSG='SIGTERM' ;; - esac - [ $CODE -ne 124 ] && sed -i '$d' "$output" - test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output" - else - printf '\n[code]: %s' "$CODE" >>"$output" - fi - - printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output - test -n "$is_debug" && is_debug_string=true || is_debug_string=false - printf '\n[debug]: %s' "$is_debug_string" >>$output - return $CODE -} - -compile_source() { - src="$1" - bin="$2" - output="$3" - flags="$4" - - test -f "$bin" && rm "$bin" || true - g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output" - CODE=$? - - if [ $CODE -gt 0 ]; then - printf '\n[code]: %s' "$CODE" >>"$output" - return $CODE - else - echo '' >"$output" - return 0 - fi -} diff --git a/cses/dynamic-programming/scripts/debug.sh b/cses/dynamic-programming/scripts/debug.sh deleted file mode 100644 index 2979422..0000000 --- a/cses/dynamic-programming/scripts/debug.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -DBG_BIN="${BASE}.debug" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -DBG_BIN="build/$DBG_BIN" - -compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/cses/dynamic-programming/scripts/run.sh b/cses/dynamic-programming/scripts/run.sh deleted file mode 100644 index ab9aa7d..0000000 --- a/cses/dynamic-programming/scripts/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -RUN_BIN="${BASE}.run" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -RUN_BIN="build/$RUN_BIN" - -compile_source "$SRC" "$RUN_BIN" "$OUTPUT" "" -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/cses/dynamic-programming/scripts/utils.sh b/cses/dynamic-programming/scripts/utils.sh deleted file mode 100644 index e99b25b..0000000 --- a/cses/dynamic-programming/scripts/utils.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -execute_binary() { - binary="$1" - input="$2" - output="$3" - - start=$(date '+%s.%N') - timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - CODE=$? - end=$(date '+%s.%N') - truncate -s "$(head -n 1000 "$output" | wc -c)" "$output" - - if [ $CODE -ge 124 ]; then - MSG='' - case $CODE in - 124) MSG='TIMEOUT' ;; - 128) MSG='SIGILL' ;; - 130) MSG='SIGABRT' ;; - 131) MSG='SIGBUS' ;; - 136) MSG='SIGFPE' ;; - 135) MSG='SIGSEGV' ;; - 137) MSG='SIGPIPE' ;; - 139) MSG='SIGTERM' ;; - esac - [ $CODE -ne 124 ] && sed -i '$d' "$output" - test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output" - else - printf '\n[code]: %s' "$CODE" >>"$output" - fi - - printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output - return $CODE -} - -compile_source() { - src="$1" - bin="$2" - output="$3" - flags="$4" - - test -f "$bin" && rm "$bin" || true - g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output" - CODE=$? - - if [ $CODE -gt 0 ]; then - printf '\n[code]: %s' "$CODE" >>"$output" - return $CODE - else - echo '' >"$output" - return 0 - fi -} diff --git a/cses/graph-algorithms/scripts/debug.sh b/cses/graph-algorithms/scripts/debug.sh deleted file mode 100644 index 1e63f37..0000000 --- a/cses/graph-algorithms/scripts/debug.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -DBG_BIN="${BASE}.debug" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -DBG_BIN="build/$DBG_BIN" - -compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT" true -exit $? diff --git a/cses/graph-algorithms/scripts/run.sh b/cses/graph-algorithms/scripts/run.sh deleted file mode 100644 index ab9aa7d..0000000 --- a/cses/graph-algorithms/scripts/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -RUN_BIN="${BASE}.run" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -RUN_BIN="build/$RUN_BIN" - -compile_source "$SRC" "$RUN_BIN" "$OUTPUT" "" -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/cses/graph-algorithms/scripts/utils.sh b/cses/graph-algorithms/scripts/utils.sh deleted file mode 100644 index e4cf8f8..0000000 --- a/cses/graph-algorithms/scripts/utils.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh - -execute_binary() { - binary="$1" - input="$2" - output="$3" - is_debug="$4" - - start=$(date '+%s.%N') - if [ -n "$is_debug" ]; then - asan="$(ldconfig -p | grep libasan.so | head -n1 | awk '{print $4}')" - LD_PRELOAD="$asan" timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - else - timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - fi - CODE=$? - end=$(date '+%s.%N') - truncate -s "$(head -n 1000 "$output" | wc -c)" "$output" - - if [ $CODE -ge 124 ]; then - MSG='' - case $CODE in - 124) MSG='TIMEOUT' ;; - 128) MSG='SIGILL' ;; - 130) MSG='SIGABRT' ;; - 131) MSG='SIGBUS' ;; - 136) MSG='SIGFPE' ;; - 135) MSG='SIGSEGV' ;; - 137) MSG='SIGPIPE' ;; - 139) MSG='SIGTERM' ;; - esac - [ $CODE -ne 124 ] && sed -i '$d' "$output" - test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output" - else - printf '\n[code]: %s' "$CODE" >>"$output" - fi - - printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output - test -n "$is_debug" && is_debug_string=true || is_debug_string=false - printf '\n[debug]: %s' "$is_debug_string" >>$output - return $CODE -} - -compile_source() { - src="$1" - bin="$2" - output="$3" - flags="$4" - - test -f "$bin" && rm "$bin" || true - g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output" - CODE=$? - - if [ $CODE -gt 0 ]; then - printf '\n[code]: %s' "$CODE" >>"$output" - return $CODE - else - echo '' >"$output" - return 0 - fi -} diff --git a/cses/introductory-problems/scripts/debug.sh b/cses/introductory-problems/scripts/debug.sh deleted file mode 100644 index 2979422..0000000 --- a/cses/introductory-problems/scripts/debug.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -DBG_BIN="${BASE}.debug" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -DBG_BIN="build/$DBG_BIN" - -compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/cses/introductory-problems/scripts/run.sh b/cses/introductory-problems/scripts/run.sh deleted file mode 100644 index ab9aa7d..0000000 --- a/cses/introductory-problems/scripts/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -RUN_BIN="${BASE}.run" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -RUN_BIN="build/$RUN_BIN" - -compile_source "$SRC" "$RUN_BIN" "$OUTPUT" "" -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/cses/introductory-problems/scripts/utils.sh b/cses/introductory-problems/scripts/utils.sh deleted file mode 100644 index e99b25b..0000000 --- a/cses/introductory-problems/scripts/utils.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -execute_binary() { - binary="$1" - input="$2" - output="$3" - - start=$(date '+%s.%N') - timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - CODE=$? - end=$(date '+%s.%N') - truncate -s "$(head -n 1000 "$output" | wc -c)" "$output" - - if [ $CODE -ge 124 ]; then - MSG='' - case $CODE in - 124) MSG='TIMEOUT' ;; - 128) MSG='SIGILL' ;; - 130) MSG='SIGABRT' ;; - 131) MSG='SIGBUS' ;; - 136) MSG='SIGFPE' ;; - 135) MSG='SIGSEGV' ;; - 137) MSG='SIGPIPE' ;; - 139) MSG='SIGTERM' ;; - esac - [ $CODE -ne 124 ] && sed -i '$d' "$output" - test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output" - else - printf '\n[code]: %s' "$CODE" >>"$output" - fi - - printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output - return $CODE -} - -compile_source() { - src="$1" - bin="$2" - output="$3" - flags="$4" - - test -f "$bin" && rm "$bin" || true - g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output" - CODE=$? - - if [ $CODE -gt 0 ]; then - printf '\n[code]: %s' "$CODE" >>"$output" - return $CODE - else - echo '' >"$output" - return 0 - fi -} diff --git a/cses/range-queries/scripts/debug.sh b/cses/range-queries/scripts/debug.sh deleted file mode 100644 index 2979422..0000000 --- a/cses/range-queries/scripts/debug.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -DBG_BIN="${BASE}.debug" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -DBG_BIN="build/$DBG_BIN" - -compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/cses/range-queries/scripts/run.sh b/cses/range-queries/scripts/run.sh deleted file mode 100644 index ab9aa7d..0000000 --- a/cses/range-queries/scripts/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -RUN_BIN="${BASE}.run" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -RUN_BIN="build/$RUN_BIN" - -compile_source "$SRC" "$RUN_BIN" "$OUTPUT" "" -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/cses/range-queries/scripts/utils.sh b/cses/range-queries/scripts/utils.sh deleted file mode 100644 index e99b25b..0000000 --- a/cses/range-queries/scripts/utils.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -execute_binary() { - binary="$1" - input="$2" - output="$3" - - start=$(date '+%s.%N') - timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - CODE=$? - end=$(date '+%s.%N') - truncate -s "$(head -n 1000 "$output" | wc -c)" "$output" - - if [ $CODE -ge 124 ]; then - MSG='' - case $CODE in - 124) MSG='TIMEOUT' ;; - 128) MSG='SIGILL' ;; - 130) MSG='SIGABRT' ;; - 131) MSG='SIGBUS' ;; - 136) MSG='SIGFPE' ;; - 135) MSG='SIGSEGV' ;; - 137) MSG='SIGPIPE' ;; - 139) MSG='SIGTERM' ;; - esac - [ $CODE -ne 124 ] && sed -i '$d' "$output" - test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output" - else - printf '\n[code]: %s' "$CODE" >>"$output" - fi - - printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output - return $CODE -} - -compile_source() { - src="$1" - bin="$2" - output="$3" - flags="$4" - - test -f "$bin" && rm "$bin" || true - g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output" - CODE=$? - - if [ $CODE -gt 0 ]; then - printf '\n[code]: %s' "$CODE" >>"$output" - return $CODE - else - echo '' >"$output" - return 0 - fi -} diff --git a/cses/sorting-and-searching/scripts/debug.sh b/cses/sorting-and-searching/scripts/debug.sh deleted file mode 100644 index 2979422..0000000 --- a/cses/sorting-and-searching/scripts/debug.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -DBG_BIN="${BASE}.debug" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -DBG_BIN="build/$DBG_BIN" - -compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/cses/sorting-and-searching/scripts/run.sh b/cses/sorting-and-searching/scripts/run.sh deleted file mode 100644 index ab9aa7d..0000000 --- a/cses/sorting-and-searching/scripts/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -RUN_BIN="${BASE}.run" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -RUN_BIN="build/$RUN_BIN" - -compile_source "$SRC" "$RUN_BIN" "$OUTPUT" "" -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/cses/sorting-and-searching/scripts/utils.sh b/cses/sorting-and-searching/scripts/utils.sh deleted file mode 100644 index e99b25b..0000000 --- a/cses/sorting-and-searching/scripts/utils.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -execute_binary() { - binary="$1" - input="$2" - output="$3" - - start=$(date '+%s.%N') - timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - CODE=$? - end=$(date '+%s.%N') - truncate -s "$(head -n 1000 "$output" | wc -c)" "$output" - - if [ $CODE -ge 124 ]; then - MSG='' - case $CODE in - 124) MSG='TIMEOUT' ;; - 128) MSG='SIGILL' ;; - 130) MSG='SIGABRT' ;; - 131) MSG='SIGBUS' ;; - 136) MSG='SIGFPE' ;; - 135) MSG='SIGSEGV' ;; - 137) MSG='SIGPIPE' ;; - 139) MSG='SIGTERM' ;; - esac - [ $CODE -ne 124 ] && sed -i '$d' "$output" - test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output" - else - printf '\n[code]: %s' "$CODE" >>"$output" - fi - - printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output - return $CODE -} - -compile_source() { - src="$1" - bin="$2" - output="$3" - flags="$4" - - test -f "$bin" && rm "$bin" || true - g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output" - CODE=$? - - if [ $CODE -gt 0 ]; then - printf '\n[code]: %s' "$CODE" >>"$output" - return $CODE - else - echo '' >"$output" - return 0 - fi -} diff --git a/usaco/bronze/complete-search/scripts/debug.sh b/usaco/bronze/complete-search/scripts/debug.sh deleted file mode 100644 index 2979422..0000000 --- a/usaco/bronze/complete-search/scripts/debug.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -DBG_BIN="${BASE}.debug" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -DBG_BIN="build/$DBG_BIN" - -compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/usaco/bronze/complete-search/scripts/memdebug.sh b/usaco/bronze/complete-search/scripts/memdebug.sh deleted file mode 100644 index 0862869..0000000 --- a/usaco/bronze/complete-search/scripts/memdebug.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -DBG_BIN="${BASE}.debug" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -DBG_BIN="build/$DBG_BIN" - -compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @mem_debug_flags.txt -CODE=$? -test $CODE -gt 0 && exit $CODE - -# Use ulimit to restrict memory to 256MB (262144 KB) -# This will run the binary with memory restrictions -execute_binary_with_memory_limit "$DBG_BIN" "$INPUT" "$OUTPUT" 262144 -exit $? \ No newline at end of file diff --git a/usaco/bronze/complete-search/scripts/run.sh b/usaco/bronze/complete-search/scripts/run.sh deleted file mode 100644 index ab9aa7d..0000000 --- a/usaco/bronze/complete-search/scripts/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -RUN_BIN="${BASE}.run" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -RUN_BIN="build/$RUN_BIN" - -compile_source "$SRC" "$RUN_BIN" "$OUTPUT" "" -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/usaco/bronze/complete-search/scripts/utils.sh b/usaco/bronze/complete-search/scripts/utils.sh deleted file mode 100644 index e99b25b..0000000 --- a/usaco/bronze/complete-search/scripts/utils.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -execute_binary() { - binary="$1" - input="$2" - output="$3" - - start=$(date '+%s.%N') - timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - CODE=$? - end=$(date '+%s.%N') - truncate -s "$(head -n 1000 "$output" | wc -c)" "$output" - - if [ $CODE -ge 124 ]; then - MSG='' - case $CODE in - 124) MSG='TIMEOUT' ;; - 128) MSG='SIGILL' ;; - 130) MSG='SIGABRT' ;; - 131) MSG='SIGBUS' ;; - 136) MSG='SIGFPE' ;; - 135) MSG='SIGSEGV' ;; - 137) MSG='SIGPIPE' ;; - 139) MSG='SIGTERM' ;; - esac - [ $CODE -ne 124 ] && sed -i '$d' "$output" - test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output" - else - printf '\n[code]: %s' "$CODE" >>"$output" - fi - - printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output - return $CODE -} - -compile_source() { - src="$1" - bin="$2" - output="$3" - flags="$4" - - test -f "$bin" && rm "$bin" || true - g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output" - CODE=$? - - if [ $CODE -gt 0 ]; then - printf '\n[code]: %s' "$CODE" >>"$output" - return $CODE - else - echo '' >"$output" - return 0 - fi -} diff --git a/usaco/bronze/scripts/debug.sh b/usaco/bronze/scripts/debug.sh deleted file mode 100644 index 2979422..0000000 --- a/usaco/bronze/scripts/debug.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -DBG_BIN="${BASE}.debug" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -DBG_BIN="build/$DBG_BIN" - -compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/usaco/bronze/scripts/run.sh b/usaco/bronze/scripts/run.sh deleted file mode 100644 index ab9aa7d..0000000 --- a/usaco/bronze/scripts/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -RUN_BIN="${BASE}.run" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -RUN_BIN="build/$RUN_BIN" - -compile_source "$SRC" "$RUN_BIN" "$OUTPUT" "" -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/usaco/bronze/scripts/utils.sh b/usaco/bronze/scripts/utils.sh deleted file mode 100644 index e99b25b..0000000 --- a/usaco/bronze/scripts/utils.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -execute_binary() { - binary="$1" - input="$2" - output="$3" - - start=$(date '+%s.%N') - timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - CODE=$? - end=$(date '+%s.%N') - truncate -s "$(head -n 1000 "$output" | wc -c)" "$output" - - if [ $CODE -ge 124 ]; then - MSG='' - case $CODE in - 124) MSG='TIMEOUT' ;; - 128) MSG='SIGILL' ;; - 130) MSG='SIGABRT' ;; - 131) MSG='SIGBUS' ;; - 136) MSG='SIGFPE' ;; - 135) MSG='SIGSEGV' ;; - 137) MSG='SIGPIPE' ;; - 139) MSG='SIGTERM' ;; - esac - [ $CODE -ne 124 ] && sed -i '$d' "$output" - test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output" - else - printf '\n[code]: %s' "$CODE" >>"$output" - fi - - printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output - return $CODE -} - -compile_source() { - src="$1" - bin="$2" - output="$3" - flags="$4" - - test -f "$bin" && rm "$bin" || true - g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output" - CODE=$? - - if [ $CODE -gt 0 ]; then - printf '\n[code]: %s' "$CODE" >>"$output" - return $CODE - else - echo '' >"$output" - return 0 - fi -} diff --git a/usaco/bronze/simulation/scripts/debug.sh b/usaco/bronze/simulation/scripts/debug.sh deleted file mode 100644 index 2979422..0000000 --- a/usaco/bronze/simulation/scripts/debug.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -DBG_BIN="${BASE}.debug" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -DBG_BIN="build/$DBG_BIN" - -compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/usaco/bronze/simulation/scripts/run.sh b/usaco/bronze/simulation/scripts/run.sh deleted file mode 100644 index ab9aa7d..0000000 --- a/usaco/bronze/simulation/scripts/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -RUN_BIN="${BASE}.run" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -RUN_BIN="build/$RUN_BIN" - -compile_source "$SRC" "$RUN_BIN" "$OUTPUT" "" -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/usaco/bronze/simulation/scripts/utils.sh b/usaco/bronze/simulation/scripts/utils.sh deleted file mode 100644 index e99b25b..0000000 --- a/usaco/bronze/simulation/scripts/utils.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -execute_binary() { - binary="$1" - input="$2" - output="$3" - - start=$(date '+%s.%N') - timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - CODE=$? - end=$(date '+%s.%N') - truncate -s "$(head -n 1000 "$output" | wc -c)" "$output" - - if [ $CODE -ge 124 ]; then - MSG='' - case $CODE in - 124) MSG='TIMEOUT' ;; - 128) MSG='SIGILL' ;; - 130) MSG='SIGABRT' ;; - 131) MSG='SIGBUS' ;; - 136) MSG='SIGFPE' ;; - 135) MSG='SIGSEGV' ;; - 137) MSG='SIGPIPE' ;; - 139) MSG='SIGTERM' ;; - esac - [ $CODE -ne 124 ] && sed -i '$d' "$output" - test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output" - else - printf '\n[code]: %s' "$CODE" >>"$output" - fi - - printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output - return $CODE -} - -compile_source() { - src="$1" - bin="$2" - output="$3" - flags="$4" - - test -f "$bin" && rm "$bin" || true - g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output" - CODE=$? - - if [ $CODE -gt 0 ]; then - printf '\n[code]: %s' "$CODE" >>"$output" - return $CODE - else - echo '' >"$output" - return 0 - fi -} diff --git a/usaco/bronze/sorting/scripts/debug.sh b/usaco/bronze/sorting/scripts/debug.sh deleted file mode 100644 index 2979422..0000000 --- a/usaco/bronze/sorting/scripts/debug.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -DBG_BIN="${BASE}.debug" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -DBG_BIN="build/$DBG_BIN" - -compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/usaco/bronze/sorting/scripts/run.sh b/usaco/bronze/sorting/scripts/run.sh deleted file mode 100644 index ab9aa7d..0000000 --- a/usaco/bronze/sorting/scripts/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. ./scripts/utils.sh - -SRC="$1" -BASE=$(basename "$SRC" .cc) -INPUT="${BASE}.in" -OUTPUT="${BASE}.out" -RUN_BIN="${BASE}.run" - -test -d build || mkdir -p build -test -d io || mkdir -p io - -test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" -test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" - -test -f "io/$INPUT" || touch "io/$INPUT" -test -f "io/$OUTPUT" || touch "io/$OUTPUT" - -INPUT="io/$INPUT" -OUTPUT="io/$OUTPUT" -RUN_BIN="build/$RUN_BIN" - -compile_source "$SRC" "$RUN_BIN" "$OUTPUT" "" -CODE=$? -test $CODE -gt 0 && exit $CODE - -execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT" -exit $? diff --git a/usaco/bronze/sorting/scripts/utils.sh b/usaco/bronze/sorting/scripts/utils.sh deleted file mode 100644 index e99b25b..0000000 --- a/usaco/bronze/sorting/scripts/utils.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -execute_binary() { - binary="$1" - input="$2" - output="$3" - - start=$(date '+%s.%N') - timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - CODE=$? - end=$(date '+%s.%N') - truncate -s "$(head -n 1000 "$output" | wc -c)" "$output" - - if [ $CODE -ge 124 ]; then - MSG='' - case $CODE in - 124) MSG='TIMEOUT' ;; - 128) MSG='SIGILL' ;; - 130) MSG='SIGABRT' ;; - 131) MSG='SIGBUS' ;; - 136) MSG='SIGFPE' ;; - 135) MSG='SIGSEGV' ;; - 137) MSG='SIGPIPE' ;; - 139) MSG='SIGTERM' ;; - esac - [ $CODE -ne 124 ] && sed -i '$d' "$output" - test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output" - else - printf '\n[code]: %s' "$CODE" >>"$output" - fi - - printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output - return $CODE -} - -compile_source() { - src="$1" - bin="$2" - output="$3" - flags="$4" - - test -f "$bin" && rm "$bin" || true - g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output" - CODE=$? - - if [ $CODE -gt 0 ]; then - printf '\n[code]: %s' "$CODE" >>"$output" - return $CODE - else - echo '' >"$output" - return 0 - fi -}