模板 字尾陣列 字尾自動機

2021-08-19 22:06:50 字數 786 閱讀 2626

關於字尾自動機sam,貼乙個非常好的講解:字尾自動機學習小記

**交洛谷模板可a

傳送門:洛谷-【模板】字尾排序

#include

using

namespace

std;

const

int n=1e6+5;

char s[n];

int sa[n],t1[n],t2[n],c[n];

int n,m=555;

void suffix()

}int main()

傳送門:【模板】字尾自動機

#include

#include

#include

#include

using

namespace

std;

typedef

long

long ll;

const

int n=1e6+10;

const

int m=2e6+20;

char s[n];ll ans;

int cnt=1,cur=1,last,len;

int dis[m],sa[m],c[n];

struct bkt[m];

inline

void insert(int a,int d)

}t[cur].size=1;

}void query()

}int main()

字尾自動機模板

include include define maxc 28 using namespace std const int maxn 1e6 5 const int mod 1e9 7 typedef long long ll int len maxn 2 最長子串的長度 該節點字串數量 len x ...

模板 字尾自動機

求子串的出現次數。用類似拓撲排序的思想,從沒有出度的節點開始把他的cnt加在他的字尾連線上。include using namespace std typedef long long ll struct node void copynewnode const int l,const node n c...

字尾自動機轉字尾樹模板

終於找到教程了,現在來寫一發 題目 jzoj4072 bzoj3998 弦論 第一問 其實非常好寫,連空間都不需要多開一倍,只需要sa陣列rank陣列和height陣列就好了,dfs一次可以求出 include include include include define n 1000010 usi...