Practising 2820 ancient password problem report

Recommended for you: Get network issues from WhatsUp Gold. Not end users.



The total time limit: 1000ms memory limit: 65536kB description of the Roman emperor had a strong government organizations including the various departments. One is the secret service department. For insurance purposes, an important file transfer between the province and the province of capital letters is encrypted. Encryption method at that time the most popular is the replacement and re arrangement.

Replacement method is all the characters replaced with other characters. Some characters will happen to replace its own. For example: replacement rule can be'A'to'Y' is replaced by the next character it, replace'Z'with'A', if the word is "VICTORIOUS" it into "WJDUPSJPVT".

Arrangement method to change the original words in alphabetical order. For example: the sequence <2, 1, 5, 4, 3, 7, 6, 10, 9, 8> applied to "VICTORIOUS", will be"IVOTCIRSUO".

People soon realized alone replacing method or arrangement method, encryption is not safe. But if the combination of these two methods, then can get encryption method is very reliable. So, a lot of important information to use encryption replacement method, then the encryption result with permutation encryption method. Using two methods can be combined into "VICTORIOUS" encryption"JWPUDJSTVP".

The archaeologists found some information at a recent Shitai. It seems they are meaningless, so anyone imagine that they may be used in replacing and arrangement of the encrypted. People try to interpret the Shitai on the password, now they want to check whether the correct interpretation. They need a computer program to validate her, your task is to write the test program.

Input two lines. The first line is the Shitai text. There is no space in the text, and only uppercase English letters. The second line is to be read out the text before the encryption. The second line is composed of English letter.

Two for the number of characters in length are not more than 100. If the second lines of output by a sort of encryption methods can produce the first line of the output information, "YES", otherwise output "NO". Sample input
Sample output


 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstdlib>
 4 #include <cstring>
 5 using namespace std;
 6 const int NUM = 26;
 7 #define MAX 200
 8 int main()
 9 {
10     //freopen("F:\\input.txt","r",stdin);
12     int i,j;
13     int res[2][NUM];
14     memset(res,0,sizeof(int)*NUM*2);
16     char str[2][MAX];
17     for(i = 0 ; i <2; i++) cin>>str[i];
19     for(i = 0; i <2; i++)
20     {
21         int len = strlen(str[i]);
22         for(j = 0; j <len; j++)
23         {
24             res[i][(str[i][j]-'A')]++;
25         }
26     }
28     for(i = 0; i <NUM; i++)
29     {
30         for(j = 0; j <NUM; j++)
31         {
32             if(res[0][i] == res[1][j]) break;
33         }
34         if(j <NUM) res[1][j] = -1;
35         else break;
36     }
37     if(i <NUM) cout<<"NO"<<endl;
38     else cout<<"YES"<<endl;
40     return 0;
41 }


(1) statics the character num

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Ed at November 16, 2013 - 9:14 AM