Skip to content

Commit 0e55595

Browse files
Update lichao.sublime-snippet
1 parent ac582af commit 0e55595

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

lichao.sublime-snippet

+46-46
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
11
<snippet>
2-
<content><![CDATA[
2+
<content><![CDATA[
33
struct LiChao
44
{
5-
6-
int n, bstart, stsize;
7-
vector<pair<ll,ll>> st;
5+
6+
int n, bstart, stsize;
7+
vector<pair<ll,ll>> st;
88
9-
LiChao(int _n) {
9+
LiChao(int _n) {
1010
11-
n = _n;
12-
bstart = 1;
13-
while (bstart < n) bstart *= 2;
14-
stsize = bstart * 2 - 1;
15-
bstart--;
11+
n = _n;
12+
bstart = 1;
13+
while (bstart < n) bstart *= 2;
14+
stsize = bstart * 2 - 1;
15+
bstart--;
1616
17-
st.resize(stsize, {0, 1e18});
17+
st.resize(stsize, {0, 1e18});
1818
19-
}
19+
}
2020
21-
ll ev(pair<ll,ll> f, ll x) {
22-
return x * f.first + f.second;
23-
}
21+
ll ev(pair<ll,ll> f, ll x) {
22+
return x * f.first + f.second;
23+
}
2424
25-
void update(int c, int cmin, int cmax, pair<ll,ll> cons) {
25+
void update(int c, int cmin, int cmax, pair<ll,ll> cons) {
2626
27-
int mid = 1 + ((cmin + cmax) / 2);
27+
int mid = 1 + ((cmin + cmax) / 2);
2828
29-
ll v1 = ev(st[c], c);
30-
ll v2 = ev(st[c], mid);
29+
ll v1 = ev(st[c], cmin);
30+
ll v2 = ev(st[c], mid);
3131
32-
ll u1 = ev(cons, c);
33-
ll u2 = ev(cons, mid);
32+
ll u1 = ev(cons, cmin);
33+
ll u2 = ev(cons, mid);
3434
35-
int b1 = (u1 < v1);
36-
int b2 = (u2 < v2);
35+
int b1 = (u1 < v1);
36+
int b2 = (u2 < v2);
3737
38-
if (b2) swap(cons, st[c]);
38+
if (b2) swap(cons, st[c]);
3939
40-
if (cmin == cmax) return;
41-
if (b1 != b2) update(c * 2 + 1, cmin, mid - 1, cons);
42-
else update(c * 2 + 2, mid, cmax, cons);
40+
if (cmin == cmax) return;
41+
if (b1 != b2) update(c * 2 + 1, cmin, mid - 1, cons);
42+
else update(c * 2 + 2, mid, cmax, cons);
4343
44-
}
44+
}
4545
46-
void add(ll m, ll b) {
47-
update(0, 0, bstart, {m, b});
48-
}
46+
void add(ll m, ll b) {
47+
update(0, 0, bstart, {m, b});
48+
}
4949
50-
ll query(int c, int cmin, int cmax, ll v) {
51-
if (cmin == cmax)
52-
return ev(st[c], v);
53-
int mid = (cmin + cmax) / 2;
54-
if (v <= mid)
55-
return min(ev(st[c], v), query(c * 2 + 1, cmin, mid, v));
56-
return min(ev(st[c], v), query(c * 2 + 2, mid + 1, cmax, v));
57-
}
50+
ll query(int c, int cmin, int cmax, ll v) {
51+
if (cmin == cmax)
52+
return ev(st[c], v);
53+
int mid = (cmin + cmax) / 2;
54+
if (v <= mid)
55+
return min(ev(st[c], v), query(c * 2 + 1, cmin, mid, v));
56+
return min(ev(st[c], v), query(c * 2 + 2, mid + 1, cmax, v));
57+
}
5858
59-
ll query(ll x) {
60-
return query(0, 0, bstart, x);
61-
}
59+
ll query(ll x) {
60+
return query(0, 0, bstart, x);
61+
}
6262
6363
};
6464
]]></content>
65-
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
66-
<tabTrigger>lichao</tabTrigger>
67-
<!-- Optional: Set a scope to limit where the snippet will trigger -->
68-
<!-- <scope>source.python</scope> -->
65+
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
66+
<tabTrigger>lichao</tabTrigger>
67+
<!-- Optional: Set a scope to limit where the snippet will trigger -->
68+
<!-- <scope>source.python</scope> -->
6969
</snippet>

0 commit comments

Comments
 (0)