Lyndon分解
模板题:https://loj.ac/p/129
知识点:是while不是if
待填坑
code:
#include <iostream> #include <cstdio> #include <cstring> using namespace std; const int MAXN = 2e6 + 5; int n; char s[MAXN]; int main() { //freopen("in.txt","r",stdin); scanf("%s",s + 1); n = strlen(s + 1); int head = 1,tem = 1,k = 2; while(head <= n) { tem = head; k = head + 1; while(k <= n && s[tem] <= s[k]) { if(s[tem] == s[k]) tem++; else tem = head; k++; } while(head <= tem) { head += k - tem; printf("%d ",head - 1); } } return 0; }