Skip to content

Commit e9def1f

Browse files
committed
Added trace and debugging templates
1 parent 4a04455 commit e9def1f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

code_template.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ typedef long double LD;
1313
typedef pair<int,int> pii;
1414
typedef pair<int,pii> piii;
1515

16-
const int MAX = 100005;
16+
const int MAX = 1000005;
1717
const int LIM = 263005;
1818
const int INF = 1000000001;
1919
const LL INFL = 1000000000000000001LL;
@@ -22,6 +22,7 @@ const LD EPS = 1e-10;
2222
const double PI = acos(-1.0);
2323

2424
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
25+
#define Assert(x) {if(!(x)){cerr<<"Assertion failed at line "<<__LINE__<<": "<<#x<<" = "<<(x)<<"\n";}}
2526
#define inchar getchar//_unlocked
2627
#define outchar(x) putchar(x)//_unlocked(x)
2728
#define pb push_back
@@ -36,6 +37,10 @@ const double PI = acos(-1.0);
3637
#define present(c,x) ((c).find(x) != (c).end())
3738
#define cpresent(c,x) (find(all(c),x) != (c).end())
3839

40+
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
41+
template <typename Arg1>void __f(const char* name, Arg1&& arg1){cout<<name<<" : "<<arg1<<"\n";}
42+
template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);}
43+
3944
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
4045
template<typename T> void inPos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=false;if(c=='-')neg=true;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
4146
template<typename T> void outPos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do {snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);outchar('\n');}
@@ -48,11 +53,20 @@ template<typename T> T InverseEuler(T a, T m){return (a==1?1:power(a,m-2,m));}
4853
template<typename T> T gcd(T a, T b){return (b==0?a:__gcd(a,b));}
4954
template<typename T> T lcm(T a, T b){return (a*(b/gcd(a,b)));}
5055

56+
int a[MAX];
57+
5158
int main() {
5259
#ifndef ONLINE_JUDGE
60+
#define LOCAL 1
61+
#define DUBUG 1
5362
freopen("inp.txt", "r", stdin);
63+
#else
64+
#define LOCAL 0
65+
#define DEBUG 0
5466
#endif
5567

56-
// cerr<<tick();
68+
if (LOCAL) {
69+
cerr<<"Execution time : "<<tick();
70+
}
5771
return 0;
5872
}

0 commit comments

Comments
 (0)