摘要: 马拉车算法与kmp算法的优化方法基本一样,就是把已经求出来的回文片段用来算接下来要求的回文中心(来回颠倒),在此附上一道马拉车算法题目的代码。 点击查看代码 #include <bits/stdc++.h> using namespace std; int main() { ios::sync_wi 阅读全文
posted @ 2026-07-14 20:58 hybrz 阅读(1) 评论(0) 推荐(0)
摘要: kmp算法的核心就是pi数组,pi[i]所表示的是在字符串s的子串s[0-i]中,最长的真前缀与后缀相等的长度。 pi数组的求法: 点击查看代码 vector<int> pi(n); for (int i = 1; i < n; i++) { int j = pi[i - 1]; while (j 阅读全文
posted @ 2026-07-14 17:52 hybrz 阅读(1) 评论(0) 推荐(0)
摘要: 给出一个字符串,输出其本身以及其循环位移字典序最小的字符串 点击查看代码 #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; 阅读全文
posted @ 2026-07-14 17:18 hybrz 阅读(0) 评论(0) 推荐(0)