总结:
1。存储的时候要使用STL的set,一开始自己写哈希表占用内存太多,导致运算速度变慢,一直TLE。
2。字符串哈希的base还是用大一点的好,13131,最好写双哈希。
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define random(l,r) ((l)+rand()%((r)-(l)+1))
#define myset(a,v) memset((a),(v),sizeof((a)));
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
const int inf=1e9+10,L=2e5+10,base=13131,mo=33554431;
const double eps=1e-6;
int a[L],n,ans,cnt,kk[L];
ULL h1[L+1],h2[L+1],pre[L];
int main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n; pre[0]=1;
rep(i,1,n) cin>>a[i],pre[i]=pre[i-1]*base;
rep(i,1,n) h1[i]=h1[i-1]*base+a[i];
h2[n]=0; per(i,n-1,0) h2[i]=h2[i+1]*base+a[i+1];
rep(k,1,n){
set<ULL> s; s.clear();
for(int p=k;p<=n;p+=k) s.insert(min((h1[p]-h1[p-k]*pre[k]),(h2[p-k]-h2[p]*pre[k])));
int nowans=s.size();
if(nowans==ans){
kk[++cnt]=k;
}else if(nowans>ans){
kk[cnt=1]=k;
ans=nowans;
}
}
cout<<ans<<' '<<cnt<<endl;
rep(i,1,cnt) cout<<kk[i]<<' ';
return 0;
}