commit 2e53b258511ac2fd4005e54c6b12400d5785892b Author: Minseong Gwak Date: Fri Jul 10 19:13:15 2026 +0900 ps contest setting diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..348151d --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + Add: [-I, lib, --std=c++23, -DDEBUG] \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd1305a --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +/_archives/ +/_contest/ + +temp +.PS + +*.cpp +!lib/*.cpp + +.DS_Store \ No newline at end of file diff --git a/.scripts/start.1 b/.scripts/start.1 new file mode 100755 index 0000000..d900c9f --- /dev/null +++ b/.scripts/start.1 @@ -0,0 +1,72 @@ +#!/bin/bash +# version 1.0 + +path="$HOME/.PS" + +path_warning="$path/warning" +path_obj="$path/obj" +path_objmd5="$path/objmd5" +path_output="$path/output.txt" + +mkdir -p $path_warning +mkdir -p $path_obj +mkdir -p $path_objmd5 + +if [ -f "$1.cpp" ] && [ ! -z "$1.cpp" ]; then + md5=`md5sum $1.cpp | cut -f1 -d' '` + + name=`basename $1` + echo "$1.cpp : File Exist!" + echo "md5: $md5" + + if [ -e "$path_objmd5/$md5" ]; then + read -p "There's excutable file with same md5. Will you excute this?(Y/n) " yesno + + if [ -z "$yesno" ] || [[ $yesno =~ [yY] ]] || [[ $yesno =~ [yY][eE][sS] ]]; then + echo -e "---------------- \"$1.cpp(?)\" Standard Input ----------------" + "$path_objmd5/$md5" > $path_output; ret=$? + echo -e "\n-------------------- \"$1.cpp(?)\" output --------------------" + cat $path_output + echo -e "\n----------------------- \"$1.cpp(?)\" ------------------------" + + exit 0 + fi + fi + + copt="g++ $1.cpp -o $path_obj/$1 -O2 -lm -Wall -static -std=c++2a -DDEBUG -Wno-unused-result" + + echo "Now Compiling..." + + echo "## Name of Source File : $1.cpp" > "$path_warning/$1" + echo "## MD5 of Source File : $md5" >> "$path_warning/$1" + echo "## Compile command : $copt" >> "$path_warning/$1" + ctime=`date +%y%m%d%H%M%S`; echo "## Compile start time : $ctime" >> "$path_warning/$1" + + `$copt 2> $path/latest`; res=$? + echo -e "## Compile end time : $(date +%y%m%d%H%M%S)\n" >> "$path_warning/$1" + cat "$path/latest" >> "$path_warning/$1" + + echo "Compile Finished!" + + cat "$path_warning/$1" + + if [ $res -eq 0 ]; then + cp "$path_obj/$1" "$path_objmd5/$md5" + + echo -e "---------------- \"$1.cpp\" Standard Input ----------------" + "$path_obj/$1" > $path_output; ret=$? + echo -e "\n-------------------- \"$1.cpp\" output --------------------" + cat $path_output + echo -e "\n----------------------- \"$1.cpp\" ------------------------" + echo -e "\nProgram returned with $ret" + echo -e "Excutable File : $path_obj/$1\n" + else + echo "Compile Failed!" + fi +elif [ -z "$1" ]; then + echo "No string is given!" +else + echo "There's no such file!" +fi + +exit 0 diff --git a/.scripts/start.2 b/.scripts/start.2 new file mode 100755 index 0000000..8f674e7 --- /dev/null +++ b/.scripts/start.2 @@ -0,0 +1,97 @@ +#!/bin/bash +# version 2.0 + +# BASE : 0 -> executed directory (default) +# BASE : 1 -> home directory +BASE=0 +YES=0 + +while getopts uy flag; do + case "$flag" in + u) BASE=1 ;; + y) YES=1 ;; + \?) usage; exit -1 ;; + esac +done + +shift $((OPTIND - 1)) + +if [ $# -eq 1 ]; then + echo ${!1} +fi + +if [ $BASE -eq 0 ]; then + path="${PWD}/.PS" +else + path="$HOME/.PS" +fi + +path_warning="$path/warning" +path_obj="$path/obj" +path_objmd5="$path/objmd5" +path_output="$path/output.txt" + +mkdir -p $path_warning +mkdir -p $path_obj +mkdir -p $path_objmd5 + +if [ -f "$1.cpp" ] && [ ! -z "$1.cpp" ]; then + md5=`md5sum $1.cpp | cut -f1 -d' '` + + name=`basename $1` + echo "$1.cpp : File Exist!" + echo "md5: $md5" + + if [ -e "$path_objmd5/$md5" ]; then + if [ $YES -eq 0 ]; then + read -p "There's excutable file with same md5. Will you excute this?(Y/n) " yesno + fi + + if [ -z "$yesno" ] || [[ $yesno =~ [yY] ]] || [[ $yesno =~ [yY][eE][sS] ]]; then + echo -e "---------------- \"$1.cpp(?)\" Standard Input ----------------" + "$path_objmd5/$md5" > $path_output; ret=$? + echo -e "\n-------------------- \"$1.cpp(?)\" output --------------------" + cat $path_output + echo -e "\n----------------------- \"$1.cpp(?)\" ------------------------" + + exit 0 + fi + fi + + copt="g++ $1.cpp -Ilib -Iac-library -fsanitize=undefined,address -o $path_obj/$1 -O2 -lm -Wall -std=c++2a -DDEBUG -Wno-unused-result" + + echo "Now Compiling..." + + echo "## Name of Source File : $1.cpp" > "$path_warning/$1" + echo "## MD5 of Source File : $md5" >> "$path_warning/$1" + echo "## Compile command : $copt" >> "$path_warning/$1" + ctime=`date +%y%m%d%H%M%S`; echo "## Compile start time : $ctime" >> "$path_warning/$1" + + `$copt 2> $path/latest`; res=$? + echo -e "## Compile end time : $(date +%y%m%d%H%M%S)\n" >> "$path_warning/$1" + cat "$path/latest" >> "$path_warning/$1" + + echo "Compile Finished!" + + cat "$path_warning/$1" + + if [ $res -eq 0 ]; then + cp "$path_obj/$1" "$path_objmd5/$md5" + + echo -e "---------------- \"$1.cpp\" Standard Input ----------------" + "$path_obj/$1" > $path_output; ret=$? + echo -e "\n-------------------- \"$1.cpp\" output --------------------" + cat $path_output + echo -e "\n----------------------- \"$1.cpp\" ------------------------" + echo -e "\nProgram returned with $ret" + echo -e "Excutable File : $path_obj/$1\n" + else + echo "Compile Failed!" + fi +elif [ -z "$1" ]; then + echo "No string is given!" +else + echo "There's no such file!" +fi + +exit 0 diff --git a/.scripts/start.3 b/.scripts/start.3 new file mode 100755 index 0000000..dffa49e --- /dev/null +++ b/.scripts/start.3 @@ -0,0 +1,100 @@ +#!/bin/bash +# version 3.0 + +# BASE : 0 -> executed directory (default) +# BASE : 1 -> home directory +BASE=0 +YES=0 +USER_INCLUDES="" + +while getopts "uyI:" flag; do + case "$flag" in + u) BASE=1 ;; + y) YES=1 ;; + I) USER_INCLUDES="$USER_INCLUDES -I$OPTARG" ;; + \?) usage; exit -1 ;; + esac +done + +shift $((OPTIND - 1)) + +if [ $# -eq 1 ]; then + echo ${!1} +fi + +if [ $BASE -eq 0 ]; then + path="${PWD}/.PS" +else + path="$HOME/.PS" +fi + +path_warning="$path/warning" +path_obj="$path/obj" +path_objmd5="$path/objmd5" +path_output="$path/output.txt" + +mkdir -p $path_warning +mkdir -p $path_obj +mkdir -p $path_objmd5 + +if [ -f "$1.cpp" ] && [ ! -z "$1.cpp" ]; then + md5=`md5sum $1.cpp | cut -f1 -d' '` + + name=`basename $1` + echo "$1.cpp : File Exist!" + echo "md5: $md5" + + if [ -e "$path_objmd5/$md5" ]; then + if [ $YES -eq 0 ]; then + read -p "There's excutable file with same md5. Will you excute this?(Y/n) " yesno + fi + + if [ -z "$yesno" ] || [[ $yesno =~ [yY] ]] || [[ $yesno =~ [yY][eE][sS] ]]; then + echo -e "---------------- \"$1.cpp(?)\" Standard Input ----------------" + "$path_objmd5/$md5" > $path_output; ret=$? + echo -e "\n-------------------- \"$1.cpp(?)\" output --------------------" + cat $path_output + echo -e "\n----------------------- \"$1.cpp(?)\" ------------------------" + + exit 0 + fi + fi + + # copt="g++ $1.cpp -Ilib -Iac-library -fsanitize=undefined,address -o $path_obj/$1 -O2 -lm -Wall -std=c++2a -DDEBUG -Wno-unused-result" + copt="g++ $1.cpp $USER_INCLUDES -fsanitize=undefined,address -o $path_obj/$1 -O2 -lm -Wall -std=c++2a -DDEBUG -Wno-unused-result" + + echo "Now Compiling..." + + echo "## Name of Source File : $1.cpp" > "$path_warning/$1" + echo "## MD5 of Source File : $md5" >> "$path_warning/$1" + echo "## Compile command : $copt" >> "$path_warning/$1" + ctime=`date +%y%m%d%H%M%S`; echo "## Compile start time : $ctime" >> "$path_warning/$1" + + `$copt 2> $path/latest`; res=$? + echo -e "## Compile end time : $(date +%y%m%d%H%M%S)\n" >> "$path_warning/$1" + cat "$path/latest" >> "$path_warning/$1" + + echo "Compile Finished!" + + cat "$path_warning/$1" + + if [ $res -eq 0 ]; then + cp "$path_obj/$1" "$path_objmd5/$md5" + + echo -e "---------------- \"$1.cpp\" Standard Input ----------------" + "$path_obj/$1" > $path_output; ret=$? + echo -e "\n-------------------- \"$1.cpp\" output --------------------" + cat $path_output + echo -e "\n----------------------- \"$1.cpp\" ------------------------" + echo -e "\nProgram returned with $ret" + echo -e "Excutable File : $path_obj/$1\n" + else + echo "Compile Failed!" + fi +elif [ -z "$1" ]; then + echo "No string is given!" +else + echo "There's no such file!" +fi + +exit 0 diff --git a/.scripts/start.4 b/.scripts/start.4 new file mode 100755 index 0000000..00269cd --- /dev/null +++ b/.scripts/start.4 @@ -0,0 +1,100 @@ +#!/bin/bash +# version 4.0 + +# BASE : 0 -> executed directory (default) +# BASE : 1 -> home directory +BASE=0 +YES=0 +USER_INCLUDES="" + +while getopts "uyI:" flag; do + case "$flag" in + u) BASE=1 ;; + y) YES=1 ;; + I) USER_INCLUDES="$USER_INCLUDES -I$OPTARG" ;; + \?) usage; exit -1 ;; + esac +done + +shift $((OPTIND - 1)) + +if [ $# -eq 1 ]; then + echo ${!1} +fi + +if [ $BASE -eq 0 ]; then + path="${PWD}/.PS" +else + path="$HOME/.PS" +fi + +path_warning="$path/warning" +path_obj="$path/obj" +path_objmd5="$path/objmd5" +path_output="$path/output.txt" + +mkdir -p $path_warning +mkdir -p $path_obj +mkdir -p $path_objmd5 + +if [ -f "$1.cpp" ] && [ ! -z "$1.cpp" ]; then + md5=`md5sum $1.cpp | cut -f1 -d' '` + + name=`basename $1` + echo "$1.cpp : File Exist!" + echo "md5: $md5" + + if [ -e "$path_objmd5/$md5" ]; then + if [ $YES -eq 0 ]; then + read -p "There's excutable file with same md5. Will you excute this?(Y/n) " yesno + fi + + if [ -z "$yesno" ] || [[ $yesno =~ [yY] ]] || [[ $yesno =~ [yY][eE][sS] ]]; then + echo -e "---------------- \"$1.cpp(?)\" Standard Input ----------------" + "$path_objmd5/$md5" > $path_output; ret=$? + echo -e "\n-------------------- \"$1.cpp(?)\" output --------------------" + cat $path_output + echo -e "\n----------------------- \"$1.cpp(?)\" ------------------------" + + exit 0 + fi + fi + + # copt="g++ $1.cpp -Ilib -Iac-library -fsanitize=undefined,address -o $path_obj/$1 -O2 -lm -Wall -std=c++2a -DDEBUG -Wno-unused-result" + copt="g++ $1.cpp $USER_INCLUDES -fsanitize=undefined,address -o $path_obj/$1 -O2 -lm -Wall -std=c++2a -DDEBUG -Wno-unused-result" + + echo "Now Compiling..." + + echo "## Name of Source File : $1.cpp" > "$path_warning/$1" + echo "## MD5 of Source File : $md5" >> "$path_warning/$1" + echo "## Compile command : $copt" >> "$path_warning/$1" + ctime=`date +%y%m%d%H%M%S`; echo "## Compile start time : $ctime" >> "$path_warning/$1" + + `$copt 2> $path/latest`; res=$? + echo -e "## Compile end time : $(date +%y%m%d%H%M%S)\n" >> "$path_warning/$1" + cat "$path/latest" >> "$path_warning/$1" + + echo "Compile Finished!" + + cat "$path_warning/$1" + + if [ $res -eq 0 ]; then + cp "$path_obj/$1" "$path_objmd5/$md5" + + echo -e "---------------- \"$1.cpp\" Standard Input ----------------" + "$path_obj/$1" > $path_output; ret=$? + echo -e "\n-------------------- \"$1.cpp\" output --------------------" + cat $path_output + echo -e "\n----------------------- \"$1.cpp\" ------------------------" + echo -e "\nProgram returned with $ret" + echo -e "Excutable File : $path_obj/$1\n" + else + echo "Compile Failed!" + fi +elif [ -z "$1" ]; then + echo "No string is given!" +else + echo "There's no such file!" +fi + +exit 0 diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..2bceb54 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,56 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Single File PS Compile & Run with 'start'", + "type": "shell", + "command": "${workspaceFolder}/start", + "args": [ + "${fileBasenameNoExtension}" + ], + "options": { "cwd": "${fileDirname}" }, + "group": { "kind": "build", "isDefault": true }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "showReuseMessage": true, + "clear": false + } + }, + { + "label": "Expand Main Code", + "type": "shell", + "command": "${workspaceFolder}/expand", + "args": ["-d", "${workspaceFolder}", "${fileBasenameNoExtension}", ">temp"], + "options": { "cwd": "${fileDirname}" }, + "group": { "kind": "test", "isDefault": true }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "showReuseMessage": true, + "clear": false + } + }, + { + "label": "Single File PS Compile & Run", + "type": "shell", + "command": "/usr/bin/g++", + "args": [ + "${fileBasename}", + "-o${fileBasenameNoExtension}", + "-O2", "-lm", "-Wall", "-static", "-std=c++2a", + "-DDEBUG", "-Wno-unused-result" + ], + "options": { + }, + "group": { + "kind": "build", + "isDefault": false + } + } + ] +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..73679c8 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Perfect PS Contest setting + diff --git a/start b/start new file mode 120000 index 0000000..e35c6a3 --- /dev/null +++ b/start @@ -0,0 +1 @@ +.scripts/start.3 \ No newline at end of file