- バグの出にくいコードを書きましょう。
- 大雑把に考えましょう。
- バグの出にくいコードを書きましょう。
- 最適化は最後の最後で。
- バグの出にくいコードを書きましょう。
.PHONY: all
all: tester
tester: main.o HOGE.o util.o
g++ -g -pg -O2 -Wall main.o HOGE.o util.o -o tester
main.o: src/main.cpp src/common.h
g++ -c -g -pg -O2 -Wall src/main.cpp
util.o: src/util.cpp src/common.h src/util.h
g++ -c -g -pg -O2 -Wall src/util.cpp
HOGE.o: src/HOGE.cpp src/common.h src/util.h
g++ -c -g -pg -O2 -Wall src/HOGE.cpp
check: check_HOGE check_util
touch check
check_HOGE: src/HOGE.cpp src/common.h src/util.h
g++ -Wall -fsyntax-only src/HOGE.cpp
touch check_HOGE
check_util: src/util.h src/util.cpp src/common.h
g++ -Wall -fsyntax-only src/util.cpp
touch check_util
.PHONY: clean
clean: rm -f tester main.o util.o HOGE.o
f=$(date | sed "s/ //g")
echo "// $f" > submit.cpp
echo "#define SUBMIT" >> submit.cpp
cat src/common.h src/util.h src/util.cpp src/HOGE.cpp >> submit.cpp
cp submit.cpp backup/$f.cpp
while(true); do
make check
sleep 3
done
#define SUBMIT
#ifndef COMMON_H
#define COMMON_H
#include <cstdio>
#include <sys/time.h>
using namespace std;
typedef long long int64;
typedef double time_type;
#ifndef SUBMIT
#define SHOW
#define DBG
#endif
#ifdef SHOW
#define LOG(...) fprintf(stderr, __VA_ARGS__)
#else
#define LOG(...)
#endif
#ifdef DBG
#define ASSERT(expr) assert(expr)
#else
#define ASSERT(expr)
#endif
struct HOGE{
int solve(int x);
};
#endif
#ifndef UTIL_H
#define UTIL_H
#ifndef SUBMIT
#include "common.h"
#endif
void set_time();
time_type get_time();
#endif
#ifndef SUBMIT
#include "util.h"
#endif
static time_type GENERAL_START_TIME;
void set_time(){
struct timeval tv;
gettimeofday(&tv, NULL);
GENERAL_START_TIME = (tv.tv_sec * 1000000LL + tv.tv_usec) / 1000000.0;
}
time_type get_time(){
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000000LL + tv.tv_usec) / 1000000.0 - GENERAL_START_TIME;
}
#ifndef SUBMIT
#include "common.h"
#endif
int HOGE::solve(int x){
return x*x;
}