Skip to content

Commit

Permalink
Update PalindromicTree, prevent warning
Browse files Browse the repository at this point in the history
  • Loading branch information
OmeletWithoutEgg committed Apr 6, 2024
1 parent eceebef commit cd00a20
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions codes/String/PalindromicTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ struct PalindromicTree {
int cnt, num; // = #pal_suffix of this node
node(int l = 0) : nxt{},f(0),len(l),cnt(0),num(0) {}
};
vector<node> st; vector<char> s; int last, n;
vector<node> st; vector<int> s; int last, n;
void init() {
st.clear(); s.clear(); last = 1; n = 0;
st.push_back(0); st.push_back(-1);
Expand All @@ -18,7 +18,7 @@ struct PalindromicTree {
s.push_back(c -= 'a'); ++n;
int cur = getFail(last);
if (!st[cur].nxt[c]) {
int now = st.size();
int now = (int)st.size();
st.push_back(st[cur].len + 2);
st[now].f = st[getFail(st[cur].f)].nxt[c];
st[cur].nxt[c] = now;
Expand All @@ -27,10 +27,10 @@ struct PalindromicTree {
last = st[cur].nxt[c]; ++st[last].cnt;
}
void dpcnt() { // cnt = #occurence in whole str
for (int i = st.size() - 1; i >= 0; i--)
st[st[i].f].cnt += st[i].cnt;
for (auto nd : st | views::reverse)
st[nd.f].cnt += nd.cnt;
}
int size() { return st.size() - 2; }
int size() { return (int)st.size() - 2; }
} pt; /* string s; cin >> s; pt.init();
for (int i = 0; i < SZ(s); i++) {
int prvsz = pt.size(); pt.add(s[i]);
Expand Down

0 comments on commit cd00a20

Please sign in to comment.