## Mock CCC14S1 - Reverse Find

View as PDF

Points: 5
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
##### 2014 Mock CCC by Alex and Timothy

Alice has an intense, but secret crush on her friend Bob, though she's pretty sure it's not mutual. She would like to learn about his interactions with other girls that may end up being her competition. After paying for some spy training, she managed to find her way into Bob's apartment. Bob had just left to run some errands, and he happened to have left his instant messaging program open. Alice is now hanging on a rope from Bob's ceiling in front of his computer, staring directly into a chat log of all of his conversations.

She would like to bookmark the location of some keywords in the chatlog so she can look them up later when she'll have obtained the entire file. The only problem is, because she's hanging upside-down, the text is reversed and upside-down from her eyes! Luckily, she can read letters upside down, but she'll need your help bookmarking the keyword in reverse.

Specifically, given a reversed text of no more than ASCII characters, and a keyword pattern of no more than ASCII characters, Alice needs to find the index of the first occurrence of the pattern when the string is read in reverse.

#### Input Specification

Line of input contains the text string .
Line of input contains the pattern string .

#### Output Specification

Output integer—the index of the first occurrence of the pattern when the string is read in reverse. Comparisons of the text and pattern are case-sensitive. The first character of input is index , the second character is index , and so on. If the pattern cannot be reverse-found, output -1.

#### Sample Input 1

.boB m'I olleH :eM (MA03:21 ta tneS)
Bob

#### Sample Output 1

4

#### Sample Input 2

.tah eht ni tac eht :eM (MA04:21 ta tneS)
the

#### Sample Output 2

19