题意:

翻转是指其中一段长度为k的子串全部翻转

n<=200000 a[i]<=n

思路:枚举k,直接哈希判充即可

时间复杂度是n/i求和,根据定理可得是O(n log n)级别的

单哈双哈都可能被卡,我用的是单哈+哈希表判重

 const mo=;
var h1,h2,mi,c,a,head,vet,next:array[..]of longint;
n,i,p,j,st,ed,t1,t2,t3,l,ans,tot:longint; function hash1(x,y:longint):longint;
begin
hash1:=(h1[y]-int64(h1[x-])*mi[y-x+] mod mo) mod mo;
hash1:=(hash1+mo) mod mo;
end; function hash2(x,y:longint):longint;
begin
hash2:=(h2[y]-int64(h2[x-])*mi[y-x+] mod mo) mod mo;
hash2:=(hash2+mo) mod mo;
end; procedure swap(var x,y:longint);
var t:longint;
begin
t:=x; x:=y; y:=t;
end; procedure add(a,b:longint);
begin
inc(tot);
next[tot]:=head[a];
vet[tot]:=b;
head[a]:=tot;
end; function judge(u,x:longint):boolean;
var e,v:longint;
begin
e:=head[u];
while e<> do
begin
v:=vet[e];
if v=x then exit(false);
e:=next[e];
end;
exit(true);
end; begin
assign(input,'bzoj2081.in'); reset(input);
assign(output,'bzoj2081.out'); rewrite(output);
readln(n);
for i:= to n do read(a[i]);
mi[]:=;
for i:= to n do mi[i]:=int64(mi[i-])* mod mo;
for i:= to n do h1[i]:=(int64(h1[i-])*+a[i]) mod mo;
for i:= to n div do swap(a[i],a[n-i+]);
for i:= to n do h2[i]:=(int64(h2[i-])*+a[i]) mod mo;
for i:= to n do
begin
p:=; tot:=;
for j:= to n div i do
begin
st:=i*(j-)+; ed:=i*j;
t1:=hash1(st,ed); t2:=hash2(n-ed+,n-st+);
t3:=int64(t1)*t2 mod mo;
inc(t3); inc(t1); inc(t2);
if judge(t3,t1) then
begin
inc(p);
add(t3,t1);
add(t3,t2);
end;
end;
if p=ans then begin inc(l); c[l]:=i; end;
if p>ans then
begin
l:=; c[]:=i; ans:=p;
end;
for j:= to n div i do
begin
st:=i*(j-)+; ed:=i*j;
t1:=hash1(st,ed); t2:=hash2(n-ed+,n-st+);
t3:=int64(t1)*t2 mod mo;
inc(t3);
head[t3]:=;
end;
end;
writeln(ans,' ',l);
for i:= to l- do write(c[i],' ');
write(c[l]);
close(input);
close(output);
end.

最新文章

  1. 回首Java(始)
  2. &quot;只能在执行Render()的过程中调用RegisterForEventValidation&quot; 解决方案
  3. 【转】shell 教程——02 几种常见的Shell
  4. 6天通吃树结构—— 第三天 Treap树
  5. git 简单教程更新
  6. Jasper_style
  7. EHCache分布式缓存集群环境配置
  8. Netty 客户端断线重连
  9. ios开发中的深拷贝和浅拷贝
  10. Tensorboard可视化(关于TensorFlow不同版本引起的错误)
  11. flask 搭建ssl接口
  12. mysql 数据库查看表的信息
  13. AI之旅(5):正则化与牛顿方法
  14. Selenium+TestNG+Maven+Jenkins+SVN(转载)
  15. javascript的Mixins
  16. Windos 下python2.7安装 pymssql 解决方案
  17. [php] try - catch exceptiong handler
  18. ACTGame项目
  19. vmware下载存储vmdk文件后缀变-flat处理方式
  20. BZOJ4921 互质序列

热门文章

  1. c#自定义ORM框架---(泛型&amp;反射&amp;实体类扩展属性&lt;附带通用增、删、查、改&gt;)
  2. loadrunner11 安装破解,汉化包
  3. c++ gets函数
  4. HDU 4691 后缀数组+RMQ
  5. E - Cheap Kangaroo(求多个数的最大公约数)
  6. c语言数据读入---sscanf、fscanf
  7. [转]微信开发.Net 接入示例
  8. 26 c#类的组合
  9. js操作元素透明度以及浏览器兼容性
  10. Ubuntu下查看服务器cpu是否支持VT