Problem with the "Smart" Interactive Board
A high school Computer Science teacher encountered a sudden problem. The dedicated computer recording the texts displayed on the "smart" electronic board in the Computer Science lab showed a blue screen! Using special software tools, they managed to recover a portion of the disk's files in a physical format (surface reading), but without the timestamp information. Unfortunately, all the positions corresponding to the content of the "smart" electronic board were filled with characters. (The latest ones written in each position). To retrieve the timestamp information, they need to find the position in the string that is recorded on the disk, at least for one phrase that they remember writing the last time.
Example:
In the broader string A;KDLJKNF,IMBUBBLESORTDIHEWN GLM FR &JSALJFLMC, η συμβολοσειρά BUBBLESORT starts at the 13 position.
Problem:
Develop a program in one of the IOI languages that, after reading the desired symbol string, will locate the position of its 1 character in a larger string (the one contained on the disk), provided that the desired string is fully contained in the larger one.
Input Files:
The input files named matrix.in are text files with the following structure: The first line contains an integer , the number of characters in the desired text. The second line contains the sought-after text. The third line contains an integer , the number of characters in the text in which the search will be conducted. The fourth line contains the text in which the search will be conducted.
- All characters have ANSI (ASCII 33 - 254) encoding.
Output Files:
The output files named matrix.out are text files with the following structure: They contain exactly one integer (1 65534). This number indicates the position in the original matrix where the beginning of the desired symbol string was found.
Examples of Input - Output Files
1st
STDIN (matrix.in)
11
BUBBLE SORT
46
A;KDLJKNF,lMBUBBLE SORTDIHEWN GLM
FR &JSALJFLMC
STDOUT (matrix.out)
13
2nd
STDIN (matrix.in)
5
STACK
67
?><MNBVCXZ":LKJHGFDSA}{POIUYTREWQ
QWERTYUIOP[]ASDFGHJKL;'ZXCVBNM,./
STDOUT (matrix.out)
F
Notes:
- If the desired symbol string is not found in any position, the output file will have only the character as its content.
- The input files contain only the allowed characters; therefore, no correctness check is required.
- Maximum Execution Time: 1 sec.
Comments