Skip to content

Commit 06b4988

Browse files
committed
Untested bydlokod
1 parent 9e4bea0 commit 06b4988

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

aho_corasick.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ vertex* go(vertex *v, int c){
2727
else if(v == root) v->go[c] = root;
2828
else v->go[c] = go(link(v), c);
2929
}
30-
return v->to[c];
30+
return v->go[c];
3131
}
3232

3333
void add_string(string s){

alcotree.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const int maxn = 1e5;
2+
int t[2*maxn];
3+
4+
int n;
5+
6+
void build(){
7+
for(int i = n-1; i > 0; i--) t[i] = max(t[i<<1], t[i<<1|1]);
8+
}
9+
10+
void upd(int k, int x){
11+
k += n;
12+
t[k] = x;
13+
while(k > 1){
14+
t[k>>1] = max(t[k], t[k^1]);
15+
k >>= 1;
16+
}
17+
}
18+
19+
int rmq(int l, int r){
20+
int ans = 0;
21+
l += n, r += n;
22+
while(l <= r){
23+
if(l&1) ans = max(ans, t[l++]);
24+
if(!(r&1)) ans = max(ans, t[r--]);
25+
l >>= 1, r >>= 1;
26+
}
27+
return ans;
28+
}

0 commit comments

Comments
 (0)