当前位置:网站首页>Suffix automata (SAM) board from Jly
Suffix automata (SAM) board from Jly
2022-07-29 03:22:00 【Foolish last words】
struct SuffixAutomaton {
static constexpr int ALPHABET_SIZE = 26, N = 1e5;
struct Node {
int len;
int link;
int next[ALPHABET_SIZE];
Node() : len(0), link(0), next{} {}
} t[2 * N];
int cntNodes;
SuffixAutomaton() {
cntNodes = 1;
std::fill(t[0].next, t[0].next + ALPHABET_SIZE, 1);
t[0].len = -1;
}
int extend(int p, int c) {
if (t[p].next[c]) {
int q = t[p].next[c];
if (t[q].len == t[p].len + 1)
return q;
int r = ++cntNodes;
t[r].len = t[p].len + 1;
t[r].link = t[q].link;
std::copy(t[q].next, t[q].next + ALPHABET_SIZE, t[r].next);
t[q].link = r;
while (t[p].next[c] == q) {
t[p].next[c] = r;
p = t[p].link;
}
return r;
}
int cur = ++cntNodes;
t[cur].len = t[p].len + 1;
while (!t[p].next[c]) {
t[p].next[c] = cur;
p = t[p].link;
}
t[cur].link = extend(p, c);
return cur;
}
};
边栏推荐
- Shell script summary
- Several methods of converting object to string
- 2022-07-28 study notes of group 4 self-cultivation class (every day)
- C traps and defects Chapter 3 semantic "traps" 3.4 avoid "couple method"
- CUDA GDB prompt: /tmp/tmpxft**** cudafe1.stub. c: No such file or directory.
- NXP i.mx8mp-deepviewrt
- Digital image processing Chapter 10 - image segmentation
- Engineering boy: under 20 years old, ordinary but not mediocre
- Score addition and subtraction of force deduction and brushing questions (one question per day 7/27)
- Unity 之游戏特效
猜你喜欢

2022-07-28 顾宇佳 学习笔记

The Federal Reserve raised interest rates again, Powell "let go of doves" at 75 basis points, and US stocks reveled

13_ UE4 advanced_ Montage animation realizes attack while walking

C语言基础知识点汇总

NXP i.mx8mp-deepviewrt

Example analysis of while, repeat and loop loops in MySQL process control

Arm architecture and neural network

Tp5.0 applet users do not need to log in and directly obtain the user's mobile number.

Design of smoke temperature, humidity and formaldehyde monitoring based on single chip microcomputer

Detailed steps for installing MySQL 8.0 under Linux
随机推荐
AI platform, AI midrange architecture
【C】 Array
Ten thousand words detailed Google play online application standard package format AAB
2022-07-28 study notes of group 4 self-cultivation class (every day)
01-sdram: Code of initialization module
后缀自动机(sam)板子 from jly
军品研制过程-转阶段
Practical guidance for interface automation testing (Part I): what preparations should be made for interface automation
力扣刷题之数组序号计算(每日一题7/28)
西瓜书学习第六章---SVM
多行文本省略
mysql的timestamp存在的时区问题怎么解决
Shell script summary
Military product development process - transition phase
Typescript学习(一)
How to realize multi line annotation in MATLAB
Minesweeping simple version
[technology 1]
How does DataGrid export and recover the entire database data, using a single SQL file
2. Nodejs -- path (\dirname, \filname), URL URL, querystring module, mime module, various paths (relative paths), web page loading (interview questions *)