HDU 4300 clairewd's message

Source: Internet
Author: User

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 ");}}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.