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

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

Clairewd’s message

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 2512    Accepted Submission(s): 983

Problem Description
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.
 

 

Input
The 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;
 

 

Output
For each test case, output one line contains the shorest possible complete text.
 

 

Sample Input
2 abcdefghijklmnopqrstuvwxyz abcdab qwertyuiopasdfghjklzxcvbnm qwertabcde
 

 

Sample Output
abcdabcd qwertabcde
 
//在字符串中找到匹配的位置,就可以了#include
#include
#include
using namespace std;#define N 100010int p[N],a[30];char s[N],ss[30];void getNext(){ int i=0,j=-1; p[0]=-1; while(s[i]){ if(j==-1||s[i]==s[j]){//j为前缀 i++,j++; if(s[i]==s[j])p[i]=p[j]; else p[i]=j; }else j=p[j]; }}int kmp(int i){ //cout<<"pos:"<
<

 

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

你可能感兴趣的文章
常见ES6新属性
查看>>
cesium primitive方式 ————http://blog.sina.com.cn/s/blog_15e866bbe0102y0ji.html
查看>>
BZOJ 1211 [HNOI2004]树的计数
查看>>
读《用户故事与敏捷方法》
查看>>
COM编程_第一讲_深入COM框架以及实现简单的COM
查看>>
Json对象处理.将对象处理成dic数组.
查看>>
java GUI画满天星
查看>>
java面试每日一题12
查看>>
【转】使用TortoiseSVN搭建本地的版本控制库
查看>>
第五十九篇、OC录制小视频
查看>>
Struts2_day03--OGNL的#、%使用
查看>>
Javascript:getElementsByClassName
查看>>
Android音频开发之——如何播放一帧音频
查看>>
MySQL 关于存储过程那点事
查看>>
代码片段
查看>>
软工第二周个人作业
查看>>
不固定个数组,进行一一对应的组合,js将多个数组实现排列组合
查看>>
一个陌生女人的来信
查看>>
SqlServer和Oracle临时表生命周期
查看>>
jquery判断文本框输入的是非数字内容(交流QQ群:452892873)
查看>>