#P2101. ACSL 2023-2024 Intermediate Division Contest #2 ACSL Book

ACSL 2023-2024 Intermediate Division Contest #2 ACSL Book

PROBLEM DESCRIPTION

A book cipher is a method of encoding and decoding a message where the sender and the receiver both use the same text. The sender’s message is encoded by replacing each alphanumeric character in the message to be sent with the location of that character in the text using an s.w.c string representing the number of the sentence in the text (s), the number of the word in that sentence (w), and the number of the character in that word (c), all indexed starting with 11. The receiver decodes the encoded message by locating the characters in the text specified by each s.w.c string.

In this program, you will be given the text and the encoded message to be decoded. The text will use the following restrictions: A word contains only alphanumeric characters

  • All words are separated by a single space or any non-alphanumeric character (s)
  • Sentences are terminated with a period, question mark, or exclamation point and sentences are separated by exactly two spaces
  • Any keyboard character can appear in the text

The encoded message will contain multiple s.w.c strings, each separated by a single space. Create a decoded message by finding each character in the text. If an s.w.c string doesn’t refer to an alphanumeric character in the text, use a space in the decoded message.

INPUT FORMAT

Input a string representing the text to be used in the decoding and another string representing the encoded message to be decoded. The first string will be no more than 20002000 characters and the second string will be no longer than 200200 characters.

OUTPUT FORMAT

Output the decoded message as a string of characters.

SAMPLES

EXPLANATION

SAMPLE #1

Refer to book/book1.in and book/book1.ans in the contestant directory.

SAMPLE #1 Explanation

The first encoded string 3.5.1 tells you to find the 33rd sentence, the 55th word in that sentence which is “participants”, and then the first character in that word which is the lowercase letter p. All others are done in a similar fashion. The string 4.10.3 is a space because there are only 88 words in the 44th sentence.

SAMPLE #2

Refer to book/book2.in and book/book2.ans in the contestant directory.

SAMPLE #3

Refer to book/book3.in and book/book3.ans in the contestant directory.

SAMPLE #4

Refer to book/book4.in and book/book4.ans in the contestant directory.

SAMPLE #5

Refer to book/book5.in and book/book5.ans in the contestant directory.

Attachment Download

book.zip