题意:
洛谷的一个后缀数组模板题,就是对一个字符串的所有后缀进行排序。
思路:
我的错误方法,MLE了,正确的应该就是用后缀数组做,写个模板就行。
我想的是用String把所有后缀写出来,使用insert(pos, num, chr)(位置,个数,字符)函数插入字符,好像这样才不会re,也许有其他更好的方法。然后,定义cmp函数,对结构体数组排序。
这个是错误的方法,我只是想记录下,string的一些用法。正确的做法学会了后缀数组后再补。
#pragma warning(disable:4996)
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<cstring>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 10005;
const ll inf = 4e18;
const ll mod = 998244353;
char str1[1000005];
struct str
{
string s;
int index;
}s[1000006];
bool cmp(str t1, str t2)
{
return t1.s < t2.s;
//