博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[BZOJ]2806: [Ctsc2012]Cheat
阅读量:4544 次
发布时间:2019-06-08

本文共 2113 字,大约阅读时间需要 7 分钟。

题解:对于标准作文库建广义sam 预处理出查询串每个位置往前能匹配的最远位置  二分答案L 然后设dp方程为

  $$  dp[i]=max(dp[i-1],max(i-j+dp[j])\left ( i-L\geq j\geqslant i-num[i] \right )) $$

然后我们用单调队列来维护$ dp[i]-i $的最大值

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define mp make_pair#define pb push_back#define pii pair
#define link(x) for(edge *j=h[x];j;j=j->next)#define inc(i,l,r) for(int i=l;i<=r;i++)#define dec(i,r,l) for(int i=r;i>=l;i--)const int MAXN=2e6+10;const double eps=1e-8;#define ll long longusing namespace std;struct edge{int t,v;edge*next;}e[MAXN<<1],*h[MAXN],*o=e;void add(int x,int y,int vul){o->t=y;o->v=vul;o->next=h[x];h[x]=o++;}ll read(){ ll x=0,f=1;char ch=getchar(); while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();} while(isdigit(ch))x=x*10+ch-'0',ch=getchar(); return x*f;}int ch[MAXN][2],fa[MAXN],dis[MAXN];int cnt,cur,rt;void built(int x){ int last=cur;cur=++cnt;dis[cur]=dis[last]+1;int p=last; for(;p&&!ch[p][x];p=fa[p])ch[p][x]=cur; if(!p)fa[cur]=rt; else{ int q=ch[p][x]; if(dis[q]==dis[p]+1)fa[cur]=q; else{ int nt=++cnt;dis[nt]=dis[p]+1; memcpy(ch[nt],ch[q],sizeof(ch[q])); fa[nt]=fa[q];fa[q]=fa[cur]=nt; for(;ch[p][x]==q;p=fa[p])ch[p][x]=nt; } }}char s[MAXN];int num[MAXN];void ycl(char str[]){ int len=strlen(str);int len1=0;int temp=rt; for(int i=0;i
=totl&&dp[t]-t>=dp[st[totr]]-st[totr])totr--; st[++totr]=t; while(totl<=totr&&st[totl]
=9*n);}int main(){ int n=read();int m=read(); int R=0; rt=cur=cnt=1; while(m--){ cur=1;scanf("%s",s); int len=strlen(s);R=max(R,len); for(int i=0;i
>1; if(check(mid,len))ans=mid,l=mid+1; else r=mid-1; } printf("%d\n",ans); } return 0;}

  

2806: [Ctsc2012]Cheat

Time Limit: 20 Sec  Memory Limit: 256 MB
Submit: 1877  Solved: 973
[][][]

Description

Input

第一行两个整数N,M表示待检查的作文数量,和小强的标准作文库

的行数
接下来M行的01串,表示标准作文库
接下来N行的01串,表示N篇作文

Output

N行,每行一个整数,表示这篇作文的Lo 值。

Sample Input

1 2
10110
000001110
1011001100

Sample Output

4

HINT

 

输入文件不超过1100000字节

注意:题目有改动,可识别的长度不小于90%即可,而不是大于90%

转载于:https://www.cnblogs.com/wang9897/p/10354333.html

你可能感兴趣的文章
获取浏览器高宽
查看>>
C++ 智能指针
查看>>
IOS7 position:fixed 定位问题
查看>>
12.伪类选择器与伪元素的应用
查看>>
Oracle存储过程基本语法
查看>>
JS高程第八章 BOM
查看>>
python-vi
查看>>
Unix进程控制
查看>>
DNS解析过程详解
查看>>
51Nod 1181 质数中的质数(质数筛法)
查看>>
并发编程学习总结
查看>>
Xamarin.Android 上中下布局
查看>>
VS Code使用记录
查看>>
locust参数化(数据库取值)
查看>>
Google Protocol Buffers浅析(三)
查看>>
.net core 中使用Google的protoc
查看>>
Spring Cloud和Spring Boot的区别
查看>>
jquery实现图片上传前本地预览
查看>>
C# — 题库答案汇总
查看>>
docker居然需要3.10以上的内核
查看>>