字典树 复杂度 O(N2S) S为字符集大小,也可以改到O(N2logS)。
注意到在下标 i 往右移动的时候,字典树内索引是否合法具有单调性,考虑对树中每一个节点维护一个指针 curidx[u] 来把复杂度均摊到 O(N2S)
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
小红需要构造一个串 s 为串 t ,初始串 s 为空。
Scan the QR code below with WeChat to sign in
First-time scan will create your account automatically
请使用微信扫描下方二维码完成注册