Tag: String
String simulation.
A 26-letter conversion table is provided. Then you will be given a string of ciphertext + plaintext, which is called for decryption and the complete ciphertext + plaintext output.
The plaintext may be incomplete and starts enumeration from half of the string until the first plaintext is converted and can be equal to the first ciphertext.
This question has been> pitfall for a long time, with no attention> and + priority issues.
You can create a reverse table when outputting data.
# Include <cstdio> # include <cstring> # include <string> # include <queue> # include <algorithm> # include <map> # include <stack> # include <iostream> # include <list> # include <set> # include <cmath> # define INF 0x7fffffff # define EPS 1e-6 # define ll long longusing namespace STD; char table [26]; char extable [26]; char STR [1, 1000001]; int main () {int T, I; scanf ("% d", & T ); while (t --) {scanf ("% S % s", table, STR); for (I = 0; I <26; I ++) extable [Table [I]-'a'] = I; int Len = strlen (STR); If (LEN & 1) I = (LEN> 1) + 1; // I = Len> 1 + 1 wa; else I = Len> 1; int K = 0; For (; I <Len; I ++) {If (Table [STR [I]-'a']! = STR [k]) continue; else {k ++; bool OK = 0; For (Int J = I + 1; j <Len; j ++) {If (Table [STR [J]-'a']! = STR [k ++]) {OK = 1; break ;}} if (! OK) Break ;}for (Int J = 0; j <I; j ++) printf ("% C", STR [J]); for (Int J = 0; j <I; j ++) printf ("% C", extable [STR [J]-'a'] + 'A '); printf ("\ n ");}}