#P1308. Word Search in Text Editor

    ID: 14595 Type: Default 1000ms 256MiB

Word Search in Text Editor

Word Search in Text Editor

This problem requires you to implement a word search feature similar to those found in text editors. You are given a target word and an article. Your task is to count the number of times the word appears as a complete word and to find the position of its first occurrence in the article. Matching is case-insensitive and a match occurs only if the target word exactly matches an entire word in the article.

If the target word does not appear as an independent word, output a count of 0 and a position of -1.

Using the notation, let \(n\) be the number of occurrences and \(p\) be the 1-indexed position of the first occurrence, the expected output format is: n p.

inputFormat

The input consists of two lines:

  1. The first line contains the target word.
  2. The second line contains the article text.

outputFormat

Output two space-separated integers on one line: the count of the target word (matched as a whole word, case-insensitive) and the 1-indexed position of its first occurrence. If the word does not appear, output -1 as the position.

sample

word
This is a word in the text.
1 3