Debug Function :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cout << '\n'; } | |
void err(istream_iterator<string> it) {} | |
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << " "; err(++it, args...); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline int Set(ll N, ll pos){return N=N | (1LL<<pos);} | |
inline int Reset(ll N, ll pos){return N=N & ~(1LL<<pos);} | |
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline bool Equal(ld x, ld y) { return fabs(x-y) < eps; } ///x==y | |
inline bool Greater(ld x, ld y) { return (x - eps) > y; } /// x>y | |
inline bool Lesser(ld x, ld y) { return (x + eps) < y; } /// x<y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); } | |
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; } | |
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; } | |
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; } | |
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; } | |
inline ll modInverse(ll a) { return modPow(a, mod - 2); } | |
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); } |
int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
int dy[] = {+1, -1, +0, +0};
int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
int dx[] = {-2, -2, -1, -1, 1, 1, 2, 2}; ///Knight's Move
int dy[] = {-1, 1, -2, 2, -2, 2, -1, 1};
Compiler Optimization :
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
No comments:
Post a Comment