Skip to content

Commit 6bb2990

Browse files
authored
Add files via upload
1 parent 76306b0 commit 6bb2990

22 files changed

+552
-65
lines changed

BIT.sublime-snippet

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<snippet>
2+
<content><![CDATA[
3+
class BIT {
4+
private:
5+
vector <int> a;
6+
int n;
7+
8+
int get(int i) {
9+
int ans = 0;
10+
for (; i > 0; i -= i & -i)
11+
ans += a[i];
12+
return ans;
13+
}
14+
public:
15+
BIT(int _n = 0) : n(_n) {
16+
a.resize(n + 1);
17+
}
18+
19+
int get(int l, int r) {
20+
return get(r) - get(l - 1);
21+
}
22+
23+
void upd(int i, int x) {
24+
for (; i <= n; i += i & -i)
25+
a[i] += x;
26+
}
27+
};
28+
]]></content>
29+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
30+
<tabTrigger>BIT</tabTrigger>
31+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
32+
<scope>source.c++</scope>
33+
</snippet>

C++_RUN.sublime-build

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
{
2-
"cmd": ["C:\\MinGW\\bin\\g++", "${file}", "-o", "${file_path}/${file_base_name}"],
3-
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
4-
"working_dir": "${file_path}",
5-
"selector": "source.c, source.c++",
6-
"shell": "true",
7-
"variants":
8-
[
9-
{
10-
"name": "Run",
11-
"cmd": ["start", "cmd.exe", "@cmd", "/k", "${file_path}/${file_base_name}"]
12-
}
13-
]
1+
2+
{
3+
"cmd": ["g++", "-std=c++17", "${file}", "-o", "${file_path}/${file_base_name}"],
4+
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
5+
"working_dir": "${file_path}",
6+
"selector": "source.c, source.c++",
7+
8+
"variants":
9+
[
10+
{
11+
"name": "Run",
12+
"cmd": ["x-terminal-emulator", "-e", "bash", "-c", "g++ -std=c++17 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'; read -p 'Press any key to continue...'"]
13+
}
14+
]
1415
}

begin.sublime-snippet

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<snippet>
2+
<content><![CDATA[
3+
\\begin{${1:}}
4+
${1/(enumerate|itemize|list)|(description)|.*/(?1:\\item )(?2:\\item)/}$0
5+
\\end{${1:}}]]></content>
6+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
7+
<tabTrigger>BEGIN</tabTrigger>
8+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
9+
<scope>text.tex</scope>
10+
</snippet>

dijkstra.sublime-snippet

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void dijkstra(int st, const vector <vector <pii>>& gr, vector <int>& dst) {
1919
}
2020
]]></content>
2121
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
22-
<tabTrigger>dijkstra</tabTrigger>
22+
<tabTrigger>DIJKSTRA</tabTrigger>
2323
<!-- Optional: Set a scope to limit where the snippet will trigger -->
24-
<!-- <scope>source.python</scope> -->
24+
<scope>source.c++</scope>
2525
</snippet>

dinic.sublime-snippet

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<snippet>
2+
<content><![CDATA[
3+
template <typename T>
4+
class Max_flow {
5+
private:
6+
struct Edge {
7+
int v, u, idx;
8+
T c, f;
9+
};
10+
11+
const int INF = 1e9;
12+
vector <vector <int>> gr;
13+
vector <Edge> e;
14+
vector <int> dst;
15+
16+
bool bfs(int s, int t) {
17+
dst = vector <int> (sz(gr), INF);
18+
dst[s] = 0;
19+
deque <int> q = {s};
20+
while (!q.empty()) {
21+
int v = q.front();
22+
q.pop_front();
23+
for (int i : gr[v]) {
24+
int u = e[i].u;
25+
T c = e[i].c, f = e[i].f;
26+
if (c - f > 0 && dst[v] + 1 < dst[u]) {
27+
q.pb(u);
28+
dst[u] = dst[v] + 1;
29+
}
30+
}
31+
}
32+
return dst[t] < INF;
33+
}
34+
35+
vector <int> lst;
36+
37+
T dfs(int v, int t, T delta) {
38+
if (v == t || delta == 0)
39+
return delta;
40+
for (; lst[v] < sz(gr[v]); ++lst[v]) {
41+
int i = gr[v][lst[v]];
42+
int u = e[i].u;
43+
T c = e[i].c, f = e[i].f;
44+
if (dst[u] == dst[v] + 1 && c - f > 0) {
45+
if (T cur_delta = dfs(u, t, min(delta, c - f))) {
46+
e[i].f += cur_delta;
47+
e[i ^ 1].f -= cur_delta;
48+
return cur_delta;
49+
}
50+
}
51+
}
52+
return 0;
53+
}
54+
55+
T find_path(int s, int t, vector <vector <int>>& paths) {
56+
vector <bool> used(sz(gr));
57+
deque <int> edges;
58+
int v = s;
59+
while (!used[v] && v != t) {
60+
used[v] = true;
61+
int nxt = -1;
62+
for (int i : gr[v]) {
63+
int u = e[i].u;
64+
T f = e[i].f;
65+
if (f > 0) {
66+
nxt = i;
67+
break;
68+
}
69+
}
70+
if (nxt == -1)
71+
return 0;
72+
edges.pb(nxt);
73+
v = e[nxt].u;
74+
}
75+
if (used[v])
76+
while (e[edges[0]].v != v)
77+
edges.pop_front();
78+
T delta = numeric_limits<T>::max();
79+
for (int i : edges)
80+
chkmin(delta, e[i].f);
81+
for (int i : edges) {
82+
e[i].f -= delta;
83+
e[i ^ 1].f += delta;
84+
}
85+
if (!used[v]) {
86+
paths.pb({});
87+
paths.back().pb(e[0].v);
88+
for (auto i : edges)
89+
paths.back().pb(e[i].u);
90+
}
91+
return delta;
92+
}
93+
94+
public:
95+
Max_flow(int _n) {
96+
gr.resize(_n);
97+
}
98+
99+
T dinic(int s, int t) {
100+
T ans = 0;
101+
while (bfs(s, t)) {
102+
lst = vector <int> (sz(gr));
103+
while (T cur = dfs(s, t, numeric_limits<T>::max()))
104+
ans += cur;
105+
}
106+
return ans;
107+
}
108+
109+
vector <vector <int>> decompose(int s, int t) {
110+
vector <vector <int>> paths;
111+
while (find_path(s, t, paths));
112+
return paths;
113+
}
114+
115+
void add_edge(int v, int u, T c, int i = -1) {
116+
gr[v].pb(sz(e));
117+
e.pb({v, u, i, c, 0});
118+
gr[u].pb(sz(e));
119+
e.pb({u, v, i, 0, 0});
120+
}
121+
};
122+
]]></content>
123+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
124+
<tabTrigger>DINIC</tabTrigger>
125+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
126+
<scope>source.c++</scope>
127+
</snippet>

dsu.sublime-snippet

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<snippet>
22
<content><![CDATA[
3-
struct Dsu {
3+
class Dsu {
44
private:
55
int n;
66
vector <int> p, sz;
@@ -29,7 +29,7 @@ public:
2929
};
3030
]]></content>
3131
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
32-
<tabTrigger>dsu</tabTrigger>
32+
<tabTrigger>DSU</tabTrigger>
3333
<!-- Optional: Set a scope to limit where the snippet will trigger -->
34-
<!-- <scope>source.python</scope> -->
34+
<scope>source.c++</scope>
3535
</snippet>

freopen.sublime-snippet

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ freopen("${1:}.in", "r", stdin);
44
freopen("${1:}.out", "w", stdout);
55
]]></content>
66
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
7-
<tabTrigger>freopen</tabTrigger>
7+
<tabTrigger>FREOPEN</tabTrigger>
88
<!-- Optional: Set a scope to limit where the snippet will trigger -->
9-
<!-- <scope>source.python</scope> -->
9+
<scope>source.c++</scope>
1010
</snippet>

gcd.sublime-snippet

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ int gcd(int a, int b) {
77
}
88
]]></content>
99
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
10-
<tabTrigger>gcd</tabTrigger>
10+
<tabTrigger>GCD</tabTrigger>
1111
<!-- Optional: Set a scope to limit where the snippet will trigger -->
12-
<!-- <scope>source.python</scope> -->
12+
<scope>source.c++</scope>
1313
</snippet>

geometry.sublime-snippet

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int operator*(Vc a, Vc b) {
2424
};
2525
]]></content>
2626
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
27-
<tabTrigger>geomerty</tabTrigger>
27+
<tabTrigger>GEOMETRY</tabTrigger>
2828
<!-- Optional: Set a scope to limit where the snippet will trigger -->
29-
<scope></scope>
29+
<scope>source.c++</scope>
3030
</snippet>

hashing.sublime-snippet

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int get(const vector <int>& h, int l, int r, const int MOD) {
2626
2727
]]></content>
2828
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
29-
<tabTrigger>hashing</tabTrigger>
29+
<tabTrigger>HASHING</tabTrigger>
3030
<!-- Optional: Set a scope to limit where the snippet will trigger -->
31-
<!-- <scope>source.python</scope> -->
31+
<scope>source.c++</scope>
3232
</snippet>

kuhn.sublime-snippet

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<snippet>
22
<content><![CDATA[
3-
bool dfs(pii v) {
3+
bool try_kuhn(int v) {
44
if (used[v])
55
return 0;
66
used[v] = 1;
7-
for (pii u : gr[v]) {
8-
if (mt[u] == -1 || dfs(mt[u])) {
7+
for (auto u : gr[v]) {
8+
if (mt[u] == -1 || try_kuhn(mt[u])) {
99
mt[u] = v;
1010
return 1;
1111
}
@@ -14,7 +14,7 @@ bool dfs(pii v) {
1414
}
1515
]]></content>
1616
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
17-
<tabTrigger>kuhn</tabTrigger>
17+
<tabTrigger>KUHN</tabTrigger>
1818
<!-- Optional: Set a scope to limit where the snippet will trigger -->
19-
<!-- <scope>source.python</scope> -->
19+
<scope>source.c++</scope>
2020
</snippet>

lca.sublime-snippet

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int lca(int v, int u, Segtree& a) {
6060
6161
]]></content>
6262
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
63-
<tabTrigger>lca</tabTrigger>
63+
<tabTrigger>LCA</tabTrigger>
6464
<!-- Optional: Set a scope to limit where the snippet will trigger -->
65-
<!-- <scope>source.python</scope> -->
65+
<scope>source.c++</scope>
6666
</snippet>

0 commit comments

Comments
 (0)