P1308 [NOIP 2011 Junior] Count Word Occurrences

Description

Most text editors have a “find word” feature that can quickly locate the position of a specific word in an article; some can also count how many times the word appears. Now, please program to implement this feature. Specifically: given a word, output the number of times it appears in the given article and the position of its first occurrence. Note: Matching is case-insensitive, but it must be an exact match, meaning the given word must be exactly the same as an independent word in the article when case is ignored (see Sample 1). If the given word is only a part of a word in the article, it does not count as a match (see Sample 2).

Input Format

A total of $2$ lines. The first line is a string containing only letters, representing the given word. The second line is a string that may contain only letters and spaces, representing the given article.

Output Format

Output one line. If the given word is found in the article, output two integers separated by a single space: the number of occurrences of the word in the article and the position of its first occurrence (that is, when it first appears, the position of the word’s first letter in the article; the position starts from $0$). If the word does not appear in the article, output a single integer $-1$. Note: A space counts as one character position.

Explanation/Hint

Constraints $1\leq $ length of the word on the first line $\leq10$. $1\leq $ article length $\leq10^6$. NOIP 2011 Junior, Problem 2. Translated by ChatGPT 5