PDP-22 (2010) - Phase B' Junior High School (matrix)

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python

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^\text{th} 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^\text{st} 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 N\;(2 \le N \le 1024), the number of characters in the desired text. The second line contains the sought-after text. The third line contains an integer M\;(8 \le M \le 65536), 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 P (1 \le P \le 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:
  1. If the desired symbol string is not found in any position, the output file will have only the character F as its content.
  2. The input files contain only the allowed characters; therefore, no correctness check is required.
  3. N \le M
  4. Maximum Execution Time: 1 sec.

Comments

There are no comments at the moment.