Skip to content

Commit 76306b0

Browse files
authored
Add files via upload
0 parents  commit 76306b0

19 files changed

+584
-0
lines changed

C++_RUN.sublime-build

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
]
14+
}

bfs.sublime-snippet

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<snippet>
2+
<content><![CDATA[
3+
vector <int> bfs(int st) {
4+
vector <int> dst(sz(gr), INF);
5+
deque <int> q;
6+
dst[st] = 0;
7+
q.pb(st);
8+
while (!q.empty()) {
9+
int v = q.front();
10+
q.pop_front();
11+
for (auto u : gr[v]) {
12+
if (dst[v] + 1 < dst[u]) {
13+
dst[u] = dst[v] + 1;
14+
q.pb(u);
15+
}
16+
}
17+
}
18+
return dst;
19+
}
20+
]]></content>
21+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
22+
<tabTrigger>bfs</tabTrigger>
23+
24+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
25+
<!-- <scope>source.python</scope> -->
26+
</snippet>

bin_pow.sublime-snippet

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<snippet>
2+
<content><![CDATA[
3+
int bin_pow(int a, int p) {
4+
if (!p)
5+
return 1;
6+
if (p % 2)
7+
return (1LL * bin_pow(a, p - 1) * a) % MOD;
8+
return (1LL * bin_pow(a, p / 2) * bin_pow(a, p / 2)) % MOD;
9+
}
10+
]]></content>
11+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
12+
<tabTrigger>bin_pow</tabTrigger>
13+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
14+
<!-- <scope>source.python</scope> -->
15+
</snippet>

cartesiantree.sublime-snippet

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<snippet>
2+
<content><![CDATA[
3+
struct Node{
4+
int val, prior, sz$1;
5+
Node *l, *r;
6+
};
7+
8+
Node* init(int _val$2) {
9+
Node *ans = new Node();
10+
ans -> val = _val;
11+
ans -> prior = rand();
12+
ans -> sz = 1;$3
13+
return ans;
14+
}
15+
16+
int get_sz(Node *a) {
17+
if (!a)
18+
return 0;
19+
return a -> sz;
20+
}
21+
22+
void upd(Node *a) {
23+
a -> sz = get_sz(a -> l) + get_sz(a -> r) + 1;$4
24+
}
25+
26+
Node *merge(Node *a, Node *b) {
27+
if (!a)
28+
return b;
29+
if (!b)
30+
return a;
31+
if (a -> prior > b -> prior) {
32+
a -> r = merge(a -> r, b);
33+
upd(a);
34+
return a;
35+
} else {
36+
b -> l = merge(a, b -> l);
37+
upd(b);
38+
return b;
39+
}
40+
}
41+
42+
pair <Node*, Node*> split(Node *a, int k) {
43+
if (!a)
44+
return {0, 0};
45+
if (get_sz(a -> l) < k) {
46+
auto b = split(a -> r, k - get_sz(a -> l) - 1);
47+
a -> r = b.fs;
48+
upd(a);
49+
return {a, b.sc};
50+
} else {
51+
auto b = split(a -> l, k);
52+
a -> l = b.sc;
53+
upd(a);
54+
return {b.fs, a};
55+
}
56+
}
57+
]]></content>
58+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
59+
<tabTrigger>cartesiantree</tabTrigger>
60+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
61+
<!-- <scope>source.python</scope> -->
62+
</snippet>

continue.sublime-snippet

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<snippet>
2+
<content><![CDATA[
3+
continue
4+
]]></content>
5+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
6+
<tabTrigger>continue</tabTrigger>
7+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
8+
<!-- <scope>source.python</scope> -->
9+
</snippet>

dijkstra.sublime-snippet

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<snippet>
2+
<content><![CDATA[
3+
void dijkstra(int st, const vector <vector <pii>>& gr, vector <int>& dst) {
4+
dst.resize(sz(gr), INF);
5+
set <pii> s;
6+
s.emplace(0, st);
7+
dst[st] = 0;
8+
while (!s.empty()) {
9+
int v = s.begin() -> sc;
10+
s.erase(s.begin());
11+
for (pii u : gr[v]) {
12+
if (dst[v] + u.sc < dst[u.fs]) {
13+
s.erase({dst[u.fs], u.fs});
14+
dst[u.fs] = dst[v] + u.sc;
15+
s.emplace(dst[u.fs], u.fs);
16+
}
17+
}
18+
}
19+
}
20+
]]></content>
21+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
22+
<tabTrigger>dijkstra</tabTrigger>
23+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
24+
<!-- <scope>source.python</scope> -->
25+
</snippet>

dsu.sublime-snippet

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<snippet>
2+
<content><![CDATA[
3+
struct Dsu {
4+
private:
5+
int n;
6+
vector <int> p, sz;
7+
public:
8+
Dsu(int _n) {
9+
n = _n;
10+
p.resize(n, -1);
11+
sz.resize(n, 1);
12+
}
13+
14+
int get(int v) {
15+
if (p[v] == -1)
16+
return v;
17+
return p[v] = get(p[v]);
18+
}
19+
20+
void unite(int v, int u) {
21+
v = get(v), u = get(u);
22+
if (v == u)
23+
return;
24+
if (sz[v] > sz[u])
25+
swap(v, u);
26+
p[v] = u;
27+
sz[u] += sz[v];
28+
}
29+
};
30+
]]></content>
31+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
32+
<tabTrigger>dsu</tabTrigger>
33+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
34+
<!-- <scope>source.python</scope> -->
35+
</snippet>

freopen.sublime-snippet

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<snippet>
2+
<content><![CDATA[
3+
freopen("${1:}.in", "r", stdin);
4+
freopen("${1:}.out", "w", stdout);
5+
]]></content>
6+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
7+
<tabTrigger>freopen</tabTrigger>
8+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
9+
<!-- <scope>source.python</scope> -->
10+
</snippet>

gcd.sublime-snippet

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<snippet>
2+
<content><![CDATA[
3+
int gcd(int a, int b) {
4+
if (!a)
5+
return b;
6+
return gcd(b % a, a);
7+
}
8+
]]></content>
9+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
10+
<tabTrigger>gcd</tabTrigger>
11+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
12+
<!-- <scope>source.python</scope> -->
13+
</snippet>

geometry.sublime-snippet

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<snippet>
2+
<content><![CDATA[
3+
struct Vc{
4+
int x, y;
5+
Vc(int _x = 0, int _y = 0) {
6+
x = _x;
7+
y = _y;
8+
}
9+
Vc(Vc a, Vc b) {
10+
x = b.x - a.x;
11+
y = b.y - a.y;
12+
}
13+
int len() {
14+
return x * x + y * y;
15+
}
16+
};
17+
18+
int operator%(Vc a, Vc b) {
19+
return a.x * b.y - a.y * b.x;
20+
}
21+
22+
int operator*(Vc a, Vc b) {
23+
return a.x * b.x + a.y * b.y;
24+
};
25+
]]></content>
26+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
27+
<tabTrigger>geomerty</tabTrigger>
28+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
29+
<scope></scope>
30+
</snippet>

hashing.sublime-snippet

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<snippet>
2+
<content><![CDATA[
3+
vector <int> p;
4+
5+
void init_p(const int MOD) {
6+
p.resize(MAXN);
7+
p[0] = 1;
8+
forn (i, 1, sz(p))
9+
p[i] = (1LL * p[i - 1] * P) % MOD;
10+
}
11+
12+
int char_to_int(char c) {
13+
return (c - 'a' + 1);
14+
}
15+
16+
vector <int> init_h(const string& s, const int MOD) {
17+
vector <int> h(sz(s) + 1);
18+
forn (i, 1, sz(h))
19+
h[i] = (1LL * h[i - 1] * P + char_to_int(s[i - 1])) % MOD;
20+
return h;
21+
}
22+
23+
int get(const vector <int>& h, int l, int r, const int MOD) {
24+
return (h[r] - (1LL * h[l] * p[r - l]) % MOD + MOD) % MOD;
25+
}
26+
27+
]]></content>
28+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
29+
<tabTrigger>hashing</tabTrigger>
30+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
31+
<!-- <scope>source.python</scope> -->
32+
</snippet>

kuhn.sublime-snippet

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<snippet>
2+
<content><![CDATA[
3+
bool dfs(pii v) {
4+
if (used[v])
5+
return 0;
6+
used[v] = 1;
7+
for (pii u : gr[v]) {
8+
if (mt[u] == -1 || dfs(mt[u])) {
9+
mt[u] = v;
10+
return 1;
11+
}
12+
}
13+
return 0;
14+
}
15+
]]></content>
16+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
17+
<tabTrigger>kuhn</tabTrigger>
18+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
19+
<!-- <scope>source.python</scope> -->
20+
</snippet>

lca.sublime-snippet

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<snippet>
2+
<content><![CDATA[
3+
struct Segtree {
4+
private:
5+
int n;
6+
vector <pii> tr;
7+
pii neutral_tr = {INT_MAX, 0};
8+
9+
pii merge(pii a, pii b) {
10+
if (a.fs < b.fs)
11+
return a;
12+
else
13+
return b;
14+
}
15+
16+
void build(const vector <pii>& a) {
17+
forn (i, 0, n)
18+
tr[i + n] = a[i];
19+
for (int i = n - 1; i > 0; i--)
20+
tr[i] = merge(tr[2 * i], tr[2 * i + 1]);
21+
}
22+
public:
23+
Segtree(const vector <pii>& a) {
24+
n = sz(a);
25+
tr.resize(2 * n, neutral_tr);
26+
build(a);
27+
}
28+
29+
pii get(int l, int r) {
30+
pii ans = neutral_tr;
31+
for (l += n, r += n; l < r; l /= 2, r /= 2) {
32+
if (l % 2)
33+
ans = merge(ans, tr[l++]);
34+
if (r % 2)
35+
ans = merge(ans, tr[--r]);
36+
}
37+
return ans;
38+
}
39+
};
40+
41+
vector <int> first;
42+
vector <pii> euler;
43+
44+
void dfs(int v, int p, int cur_h, const vector <vector <int>>& gr) {
45+
first[v] = sz(euler);
46+
euler.eb(cur_h, v);
47+
for (int u : gr[v]) {
48+
if (u != p) {
49+
dfs(u, v, cur_h + 1, gr);
50+
euler.eb(cur_h, v);
51+
}
52+
}
53+
}
54+
55+
int lca(int v, int u, Segtree& a) {
56+
if (first[v] > first[u])
57+
swap(v, u);
58+
return a.get(first[v], first[u] + 1).sc;
59+
}
60+
61+
]]></content>
62+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
63+
<tabTrigger>lca</tabTrigger>
64+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
65+
<!-- <scope>source.python</scope> -->
66+
</snippet>

0 commit comments

Comments
 (0)