here:https://oi-wiki.org/string/sam/ 下面转自 KesdiaelKen的雷蒻论坛 来个广义后缀自动机模板题 [USACO17DEC]Standing Out from the Herd #include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int n, l[MAXN], m, s[MAXN]; long long ans[MAXN]; namespace SAM { co…
建出广义SAM,通过parent树对每个节点求出其是否仅被一个子串包含及被哪个包含. 写了无数个sam板子题一点意思都没啊 #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 #define N 200010 char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>…
Description Just like humans, cows often appreciate feeling they are unique in some way. Since Farmer John's cow s all come from the same breed and look quite similar, they want to measure uniqueness in their name s.Each cow's name has some number of…