2015
05-23

# Clairewd’s message

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.

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;

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;

2
abcdefghijklmnopqrstuvwxyz
abcdab
qwertyuiopasdfghjklzxcvbnm
qwertabcde

abcdabcd
qwertabcde

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <set>
#include <string>
using namespace std;
string s1;
string s2;
char a[30];//鍘熸潵鐨�'a'鍙樻垚浜嗕粈涔�
char b[30];//鐜板湪鐨勨�榓鈥欐槸璋�
int main ()
{
int T;
cin >> T;
while(T--)
{
cin >> s1 >> s2;
for(int i=0;i<s1.size();i++)
{
a[i] = s1[i];
b[s1[i]-'a'] = i + 'a';
}
char s ;
s = b[s2[0]-'a'];
int i;
int l = s2.size();
for(i=(s2.size() + 1)/2;i<s2.size();i++)
{
bool flag = false;
int j;
for(j=i;j<s2.size();j++)
{
if(b[s2[j-i]-'a'] != s2[j]){
flag = true;
break;
}
}
if(flag == false)
{
l = i;
break;
}
}
for(int i=0;i<l;i++)
{
cout << s2[i];
}
for(int i=0;i<l;i++)
{
cout << b[s2[i]-'a'];
}
cout << endl;
}
return 0;
}

1. 朝夕有伊西斯她的基因也没办法做到月见一样，因为她们一样的贪婪却又不是贪同一个东西……月见有时候也会为自己不平就像第九话想丢了凶匙一样再怎么样努力也没有用的想法出现！

2. 朝夕有伊西斯她的基因也没办法做到月见一样，因为她们一样的贪婪却又不是贪同一个东西……月见有时候也会为自己不平就像第九话想丢了凶匙一样再怎么样努力也没有用的想法出现！

3. 朝夕有伊西斯她的基因也没办法做到月见一样，因为她们一样的贪婪却又不是贪同一个东西……月见有时候也会为自己不平就像第九话想丢了凶匙一样再怎么样努力也没有用的想法出现！

4. 朝夕有伊西斯她的基因也没办法做到月见一样，因为她们一样的贪婪却又不是贪同一个东西……月见有时候也会为自己不平就像第九话想丢了凶匙一样再怎么样努力也没有用的想法出现！

5. 朝夕有伊西斯她的基因也没办法做到月见一样，因为她们一样的贪婪却又不是贪同一个东西……月见有时候也会为自己不平就像第九话想丢了凶匙一样再怎么样努力也没有用的想法出现！

6. 朝夕有伊西斯她的基因也没办法做到月见一样，因为她们一样的贪婪却又不是贪同一个东西……月见有时候也会为自己不平就像第九话想丢了凶匙一样再怎么样努力也没有用的想法出现！

7. 朝夕有伊西斯她的基因也没办法做到月见一样，因为她们一样的贪婪却又不是贪同一个东西……月见有时候也会为自己不平就像第九话想丢了凶匙一样再怎么样努力也没有用的想法出现！

8. 朝夕有伊西斯她的基因也没办法做到月见一样，因为她们一样的贪婪却又不是贪同一个东西……月见有时候也会为自己不平就像第九话想丢了凶匙一样再怎么样努力也没有用的想法出现！

9. 朝夕有伊西斯她的基因也没办法做到月见一样，因为她们一样的贪婪却又不是贪同一个东西……月见有时候也会为自己不平就像第九话想丢了凶匙一样再怎么样努力也没有用的想法出现！