-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.hpp
More file actions
77 lines (71 loc) · 1.66 KB
/
Copy pathdebug.hpp
File metadata and controls
77 lines (71 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once
#include <bits/stdc++.h>
#ifdef __WIN32
#ifndef ONLINE_JUDGE
// ---------- DEBUG ----------
#ifndef NODEBUG
#ifndef OUT
void de() { std::cout << "\033[0m \n"; }
#else
void de() { std::cout << "\n"; }
#endif
template <typename T, typename... Args>
void de(T a, Args... args) { std::cout << a << " ", de(args...); }
template <typename T, typename... Args>
#ifndef OUT
void debug(T a, Args... args)
{
std::cout << "\033[32m[DEBUG] \033[33m" << a << " ", de(args...);
}
#else
void debug(T a, Args... args)
{
std::cout << "[DEBUG] " << a << " ", de(args...);
}
#endif
#else
template <typename T, typename... Args>
void debug(T a, Args... args) {}
#endif
// ---------- TIMER ----------
extern int real_main();
#ifndef NOTIMER
#include <sys/time.h>
#endif
int main()
{
#ifndef NOTIMER
struct timeval tv;
gettimeofday(&tv, NULL);
long long startMS = tv.tv_sec * 1000LL + tv.tv_usec / 1000;
#endif // NOTIMER
// File IO
#ifdef IN
freopen(IN, "r", stdin);
#endif
#ifdef OUT
freopen(OUT, "w", stdout);
#endif
real_main();
#ifndef NOTIMER
struct timeval _tv;
gettimeofday(&_tv, NULL);
long long endMS = _tv.tv_sec * 1000LL + _tv.tv_usec / 1000;
#ifndef OUT
std::cout << "\033[32m[TIMER]\033[34m Program Time: " << (double(endMS) - double(startMS)) / 1000 << "s \033[0m \n";
#else
std::cout << "[TIMER] Program Time: " << (double(endMS) - double(startMS)) / 1000 << "s\n";
#endif
#endif // NOTIMER
return 0;
}
#define main real_main
// ---------- DEBUG ----------
#else
template <typename T, typename... Args>
void debug(T a, Args... args) {}
#endif
#else
template <typename T, typename... Args>
void debug(T a, Args... args) {}
#endif