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

本文共 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

你可能感兴趣的文章
php防止快速刷屏留言
查看>>
python 登录验证程序
查看>>
Linux
查看>>
限制linux 用户使用su命令转化root权限
查看>>
headfirst PMP-忽视项目职责范围会带来哪些问题?
查看>>
PHP缓存学习之redis
查看>>
以lnmp为基础搭建discuz论坛
查看>>
云计算网络基础-金老师
查看>>
Vim编辑器与Shell编辑器
查看>>
Cisco交换路由配置命令及说明
查看>>
解析sort命令
查看>>
mysql慢查询
查看>>
体会瞬间的舒爽
查看>>
我的友情链接
查看>>
关于网站访问出现的以下问题
查看>>
FFmpeg架构之其他重要数据结构的初始化
查看>>
List(二)
查看>>
Discuz论坛黑链清理教程
查看>>
committed access rate(CAR)承诺访问速率
查看>>
我的友情链接
查看>>