博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
kuangbin专题十六 KMP&&扩展KMP HDU4300 Clairewd’s message
阅读量:4943 次
发布时间:2019-06-11

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

Clairewd is a member of FBI. After several years concealing in BUPT, she intercepted some important messages and she was preparing for sending it to ykwd. They had agreed that each letter of these messages would be transfered to another one according to a conversion table.
Unfortunately, GFW(someone's name, not what you just think about) has detected their action. He also got their conversion table by some unknown methods before. Clairewd was so clever and vigilant that when she realized that somebody was monitoring their action, she just stopped transmitting messages.
But GFW knows that Clairewd would always firstly send the ciphertext and then plaintext(Note that they won't overlap each other). But he doesn't know how to separate the text because he has no idea about the whole message. However, he thinks that recovering the shortest possible text is not a hard task for you.
Now GFW will give you the intercepted text and the conversion table. You should help him work out this problem.
InputThe first line contains only one integer T, which is the number of test cases.
Each test case contains two lines. The first line of each test case is the conversion table S. S[i] is the ith latin letter's cryptographic letter. The second line is the intercepted text which has n letters that you should recover. It is possible that the text is complete.
Hint
Range of test data:
T<= 100 ;
n<= 100000;
OutputFor each test case, output one line contains the shorest possible complete text.Sample Input
2abcdefghijklmnopqrstuvwxyzabcdabqwertyuiopasdfghjklzxcvbnmqwertabcde
Sample Output
abcdabcdqwertabcde 题目意思非常绕。。。其实就是给你一个加密表,然后给你一个字符串S, 是由密文+明文构成,但是明文可能不完整。所以可以知道密文>=明文 所以就可以把S翻译一下得到T串。 S的后缀是明文(可能不完整) T的前缀是完整明文。 然后S和T匹配。存在这么一个位置 i+extend[i]>=len&&i>extend[i]  说明满足题意
1 #include
2 #include
3 #include
4 using namespace std; 5 const int maxn=100010; 6 int _,Next[maxn],extend[maxn],len; 7 char table[26],S[maxn],T[maxn],temp[125]; 8 9 void getnext() {10 Next[0]=len;11 int j=0;12 while(j+1
=len&&i>=extend[i]) break;59 }60 for(int j=0;j

 

 

转载于:https://www.cnblogs.com/ACMerszl/p/10299311.html

你可能感兴趣的文章
MySQL对时间的处理总结
查看>>
笔记四:python乱码深度剖析二
查看>>
《PHP程序员面试笔试宝典》——如何回答技术性的问题?
查看>>
【转载】Amit’s A star Page 中译文
查看>>
注册谷歌账号并验证时显示号码无法用于验证的问题
查看>>
Hive 变量和属性
查看>>
Python安装第三方库 xlrd 和 xlwt 。处理Excel表格
查看>>
课后作业-阅读任务-阅读提问-3
查看>>
Asp.Net Core 中利用QuartzHostedService 实现 Quartz 注入依赖 (DI)
查看>>
细说sqlserver索引及SQL性能优化原则
查看>>
一般数据库增量数据处理和数据仓库增量数据处理的几种策略
查看>>
centos6.5适用的国内yum源:网易、搜狐
查看>>
视频直播技术(三):低延时直播经验总结
查看>>
Application failed to start because it could not find or load the QT platform plugin “windows”
查看>>
python合并多表或两表数据
查看>>
第一个python作业题目以及代码
查看>>
Windows Azure 社区新闻综述(#71 版)
查看>>
Windows XP 的最高版本 .net framework 安装
查看>>
本机不装Oracle,使用plsql连接远程Oracle的方法
查看>>
先说一下JS的获取方法,其要比JQUERY的方法麻烦很多,后面以JQUERY的方法作对比。...
查看>>