博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 4300 Clairewd’s message KMP
阅读量:7237 次
发布时间:2019-06-29

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

题目地址: 

这道题目的题意太难理解了。

第一行给你26个字母的一段密文,对应明文是从a-z。

第二行给你前面是密文后面是明文的字符串,密文一定是完整的,但是明文可能没有也可能都有。

让你求最短的密文+明文。

例一:abcdab

最短密文:abcd,它对应的明文是abcd

所以最短密文+明文为abcdabcd

例二:qwertabcde

最短密文:qwert,它对应的明文是abcde

所以最短密文+明文为qwertabcde

有点难理解。

思路:明文的长度一定小于等于len/2,然后用后面的一半与对应的明文匹配

比如第一个例子:用dab与abcdab最大匹配为t=2,说明有两个已经是明文,从t到len-t输出后面的即为未显示的明文,

AC代码:

 

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;typedef __int64 LL;const int N=100090;const LL II=1000000007;const int INF=0x3f3f3f3f;const double PI=acos(-1.0);char word[N],yi[26],mi[26],xh[N];int wlen,next[N];void getnext(char *p){ int j=0,k=-1; next[0]=-1; while(j

 

 

转载地址:http://atofm.baihongyu.com/

你可能感兴趣的文章
微软推出首个Microsoft Azure Stack技术预览版
查看>>
Proguard语法及常用proguard.cfg代码段
查看>>
OOP 第二章作业总结
查看>>
python什么时候使用多线程,什么时候使用多进程?
查看>>
Quartz中时间表达式的设置-----corn表达式 (转)(http://www.cnblogs.com/GarfieldTom/p/3746290.html)...
查看>>
Flash Media Server 5.0 (FMS)注册码
查看>>
根据匹配词个数排序
查看>>
Xcopy命令参数使用介绍
查看>>
Java ArrayList、Vector和LinkedList等的差别与用法(转)
查看>>
用flock命令解决Linux计划任务重复执行
查看>>
[再寄小读者之数学篇](2014-06-19 两个分部积分)
查看>>
Opencv cvCircle函数
查看>>
CMD命令 - yanghj - 博客园
查看>>
mysql 加入列,改动列,删除列。
查看>>
网格导入设置 Import settings for Meshes
查看>>
m2014-architecture-imgserver->Lighttpd +mod_mem_cache的效果简直太好了
查看>>
POSIX semaphore: sem_open, sem_close, sem_post, sem_wait
查看>>
wcf中的使用全双工通信(转)
查看>>
PowerDesigner生成Access数据库
查看>>
20140720感受
查看>>