https://github.com/exoad/sandbox
My programming notes
https://github.com/exoad/sandbox
Last synced: about 1 year ago
JSON representation
My programming notes
- Host: GitHub
- URL: https://github.com/exoad/sandbox
- Owner: exoad
- Created: 2021-08-02T11:19:58.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-31T20:30:03.000Z (about 1 year ago)
- Last Synced: 2025-04-13T23:08:30.963Z (about 1 year ago)
- Language: C++
- Homepage:
- Size: 6.38 MB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Practice
This is Jack Meng's coding practice repo. Most of the things here are just my solves to online judges like LeetCode, AtCoder, etc., but I also write notes and other helpful stuffs.
:)
## Content
* [`./Solves/`](./Solves/) - Contains all of my general programming solutions and notes **as of October 2024**. These are mostly for OJs like Codeforces, Atcoder, LeetCode, etc..
* [`./Notes/`](./Notes/) - All of my documented notes that I hopefully have formatted properly. They cover various topics. **THE LATEX MAY BE MESSED UP FROM GITHUB'S BUILTIN RENDERER. I use KaTeX by default to render them on my end.**
* [`./Old-Solves/`](./Old-Solves/) - Contains all of my solutions from my past (pre 2023 era).
* [`Resources.md`](./Resources.md) - Contains helpful resources that I have found to be extremely helpful.
* [`To_Learn.md`](./To_Learn.md) - Are just simple reminders of what I still need to work on.
* [`interesting.txt`](./interesting.txt) - This is my old list of resources.
## Coding Templates
Located [here](./Solves/modules/googer.cxx)
```cxx
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-label"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#pragma GCC diagnostic ignored "-Wmissing-braces"
#pragma GCC diagnostic ignore "-Wmaybe-uninitialized"
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("Ofast", "unroll-loops")
#ifdef __linux__
# include
#endif
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using str=string;
#define TRUE 1
#define FALSE 0
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define RANGE(a,b) for(int i=a;i<=b;i++)
#define PI 3.14159265358979323846
#ifdef LOCAL_JUDGE_HOST
# define __trace(x) cerr<<"["<<__LINE__<<"] "<<#x<<"@"<<&x<<"="<
inline void partial_sum(vector x)
{
partial_sum(all(x),x.begin());
}
inline void setIO(str name="")
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
if (int(name.size()))
{
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
}
int gcd(int a,int b)
{
return a==0||a==b?b:b==0||b%a==0?a:a>b?gcd(b,a):gcd(a,b%a);
}
inline int low_bit(int x)
{
return x&(-x);
}
#ifdef __linux__
ostream& operator<<(ostream& os,const __int128_t& v)
{
if (!v)
os<<"0";
__int128_t tmp=v<0?(os<<"-",-v):v;
string s;
while (tmp)
{
s+='0'+(tmp%10);
tmp/=10;
}
return reverse(all(s)),os<
class Graph
{
public:
struct Edge
{
int from;
int to;
T weight;
Edge(int from,int to,T weight) :from(from),to(to),weight(weight)
{
}
};
vector edges;
vector> ver;
int n;
Graph(int n) :n(n)
{
ver.resize(n);
}
virtual int addEdge(const Edge& edge)=0;
};
template
class UndirectedGraph :public Graph
{
public:
UndirectedGraph(int n) :Graph(n)
{
}
int addEdge(const typename Graph::Edge& edge) override
{
assert(0<=edge.from&&edge.from::n&&0<=edge.to&&edge.to::n);
int id=(int)Graph::edges.size();
Graph::ver[edge.from].pb(id);
Graph::g[edge.to].pb(id);
Graph::edges.pb(edge);
return id;
}
};
template
class DirectedGraph :public Graph
{
public:
DirectedGraph(int n) :Graph(n)
{
}
int addEdge(const typename Graph::Edge& edge) override
{
assert(0<=edge.from&&edge.from::n&&0<=edge.to&&edge.to::n);
int id=(int)Graph::edges.size();
Graph::g[edge.from].pb(id);
Graph::edges.pb(edge);
return id;
}
};
struct UnionFind
{
vector uf;
int n;
UnionFind(int n) :uf(n,-1),n(n)
{
}
int find(int v)
{
return uf[v]<0?v:uf[v]=find(uf[v]);
}
bool join(int v,int w)
{
if ((v=find(v))==(w=find(w)))
return false;
if (uf[v]>uf[w])
::swap(v,w);
uf[v]+=uf[w];
uf[w]=v;
n--;
return true;
}
bool connected(int v,int w)
{
return find(v)==find(w);
}
int size(int v)
{
return -uf[find(v)];
}
};
template
class BIT
{
private:
int sz;
vector bit,arr;
public:
BIT(int sz):sz(sz),bit(sz+1),arr(sz)
{
}
void add(int i,int v)
{
arr[i]+=v;
i++;
for(;i<=sz;i+=low_bit(i))
bit[i]+=v;
}
T psum(int i)
{
i++;
T sum=0;
for(;i>0;i-=low_bit(i))
sz+=bit[i];
return sum;
}
void set(int i,int v)
{
add(i,v-arr[i]);
}
};
};
signed main()
{
setIO();
return 0;
}
```