https://konnyakuxzy.github.io/BZPRO/JudgeOnline/2740.html 题解讲的很清楚了 (好像等于的情况应该归入case2而不是case1?并不确定) 具体方法: 将串翻转,找到字典序最小且最短的后缀,然后找到以这个后缀为纯循环节的最长后缀T,则第一步是将这个后缀T提到最前面: 然后第二步是把整个串除T外部分变为其循环同构串的最小表示. 要找到字典序最小且最短的后缀,只要找到整个串的最小表示法(设最小表示法在位置i开始),然后找到S[i..n]的最短…
题目大意:给定一个串S,求最小表示法 n<=1000W,实在不敢写后缀自己主动机,就去学了最小表示法= = 记得用unsigned char不然WA= = 数据真是逗- - #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define M 10001000 using namespace std; int n; unsigned char s[…
本来想用来练习后缀自动机的,但是100w有点虚(事实证明确实T掉了). 只好上最小表示法. #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define F(i,j,k) for (int i=j;i<=k;++i) #define D(i,j,k) for (int i=j;i>=k;--i)…
题目描述 给定一个字符串S = {S1, S2, S3 … Sn}, 如果在串SS中, 子串T(|T| = n)为所有长度为n的SS的字串中最小的(字符串的比较), 则称T为”奇怪的字串”. 你的任务就是找出这个字符串. 输入 读入两行, 第一行为n, 第二行为字符串S. 输出 将”奇怪的字串” T输出输入样例 样例输入 10 asdfasdfas 样例输出 asasdfasdf 提示 数据范围对于100%的数据, 保证n≤10000000;给定的字符串中的字符保证在#33 ~ #254之间.…
*N]; //储存临时串 *N];//中间记录 int Manacher(char tmp[]) { int len=strlen(tmp); ; ;i<len;i++) { s[cnt++]='#'; s[cnt++]=tmp[i]; } s[cnt++]='#'; memset(save,,sizeof(save)); ,p=; ; ;i<cnt-;i++) { if(i>=p) { ; &&s[i+num]==s[i-num]) { num++; } p=i+num…
Time Limit: 10 Sec  Memory Limit: 259 MB 给定一个字符串S = {S1, S2, S3 … Sn}, 如果在串SS中, 子串T(|T| = n)为所有长度为n的SS的字串中最小的(字符串的比较), 则称T为”奇怪的字串”. 你的任务就是找出这个字符串. 读入两行, 第一行为n, 第二行为字符串S. 将”奇怪的字串” T输出输入样例 Sample Input 10 asdfasdfas Sample Output asasdfasdf HINT 对于100%…
一开始没太看懂什么意思,拿笔反复推了一遍才大概知道最大最小表示法是怎么求的,感觉太神奇了... #include <iostream> #include <cstdio> #include <string.h> #pragma warning ( disable : 4996 ) using namespace std; inline int Max(int a,int b) { return a>b?a:b; } inline int Min(int a,int…
最小标示法:给定一个字符串,不断将其最后一个字符放到开头,最终会得到n个字符串,称这n个字符串循环同构,这些字符串中字典序最小的一个,就是最小表示法 #include<iostream> #include<cstring> #include<cstdio> using namespace std; #define maxn 1000005 int len; int main(){ int t; cin>>t; while(t--){ ]={}; cin>…
最小表示法就是一个字符串构成一个环,找以哪个点为开头字典序最小. 然后我们就可以用n2的算法愉快的做啦~实际上有O(n)的做法的,就是用两个指针扫,如果这两个位置的字典序相等,就一起往后,如果某一个大,就把那个指针指到大的那个的后面. 每次至少有一个指针往后移一个,复杂度就是线性的了. (自己YY的,求不出锅) #include <iostream> #include <cstdio> #include <cstring> using namespace std; in…
Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings: String Rank SKYLONG 1 KYLONGS 2 YLONGSK 3 LONGSKY 4 ONGSKYL 5 NGSKYLO 6 GSKYLON 7 and lexicograp…