Working environment

Makefile

CFLAGS = -O3 -std=gnu++20 -Wall -Wextra -Wshadow -D_GLIBCXX_ASSERTIONS -ggdb3 -fmax-errors=2 -DLOCAL
 
.PHONY: all gen test atcoder clean

%: ~/.hash/%.cpp.md5
	g++ -o $@ $@.cpp ${CFLAGS}

solution: solution.cpp
	g++ -o solution solution.cpp ${CFLAGS}
 
all: data brute
 
gen:
	python3 gen.py > data.in
 
test:
	bash test.sh
 
atcoder:
	bash atcoder.sh
 
clean:
	rm data brute

vscodecr

#!/bin/bash
fullname=$1
extension="${fullname##*.}"
basename=${fullname##*/}
filename="${basename%.*}"

md5_hash=$(md5sum "$fullname" | awk '{ print $1 }')
hashfile=~/.hash/$filename.$extension.md5
hashcontent=''
if [ ! -f "$hashfile" ]; then
    touch $hashfile
else
	hashcontent=$(< "$hashfile")
fi
if [ "$md5_hash" != "$hashcontent" ] || [ ! -f "$basename" ]; then
	echo $md5_hash > $hashfile
fi

directory="$(realpath $1 | sed 's|\(.*\)/.*|\1|')"
current="$(pwd)"
if [[ $current != $directory ]]; then
	cd_command="cd "$directory
	eval $cd_command
fi
line1=$(head -n 1 $fullname)
line2=$(head -n 2 $fullname | tail -n 1)


GREEN='\033[1;36m'
NC='\033[0m'

regex_shebang='#!.*$'
[[ $line1 =~ $regex_shebang ]]

if [[ $? -eq 0 ]]; then
	echo ${line1:2}\ $filename.$extension
	eval ${line1:2} $filename.$extension
	exit 0
fi
if [[ "$extension" == "cpp" ]]; then
	compile_command="g++ -o "$filename" "$filename"."$extension
	run_command="./"$filename
	if [[ $line1 =~ "compile:" ]]; then
		compile_command=${line1##*compile:}
	fi
	if [[ $line1 =~ "run:" ]]; then
		run_command=${line1##*run:}
	fi
	if [[ $line2 =~ "run:" ]]; then
		run_command=${line2##*run:}
	fi
	eval $compile_command
	if [[ $? -ne 0 ]]; then
		exit 1
	fi
	if [[ $line1 =~ "g++" ]]; then
		printf "${GREEN}compile${NC} $compile_command ${GREEN}done${NC}\n"
	fi
	echo $run_command
	eval $run_command
	exit 0
fi
if [[ "$extension" == "c" ]]; then
	compile_command="gcc -o "$filename" "$filename"."$extension
	compile_run="./"$filename
	if [[ $line1 =~ "compile:" ]]; then
		compile_command=${line1##*compile:}
	fi
	if [[ $line1 =~ "run:" ]]; then
		compile_run=${line1##*run:}
	fi
	if [[ $line2 =~ "run:" ]]; then
		compile_run=${line2##*run:}
	fi
	eval $compile_command
	if [[ $? -ne 0 ]]; then
		exit 1
	fi
	printf "${GREEN}compile${NC} $compile_command ${GREEN}done${NC}\n"
	echo $run_command
	eval $run_command
	exit 0
fi
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next