2014 Mock CCC by Alex and Timothy
Problem S1: Reverse Find
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 T of no more than 1000 ASCII characters, and a keyword pattern P of no more than 100 ASCII characters, Alice needs to find the index of the first occurrence of the pattern when the string is read in reverse.
Line 1 of input contains the text string T. Line 2 of input contains the pattern string P.
Output 1 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 1, the second character is index 2, 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
Sample Input 2
.tah eht ni tac eht :eM (MA04:21 ta tneS) the
Sample Output 2
Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M
Added: Feb 27, 2014
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3