#P1308. [NOIP 2011 普及组] 统计单词数

[NOIP 2011 普及组] 统计单词数

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 22 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 00). If the word does not appear in the article, output a single integer 1-1.

Note: A space counts as one character position.

To
to be or not to be is a question

2 0


to
Did the Ottoman Empire lose its power at that time
-1

Hint

Constraints

11\leq length of the word on the first line 10\leq10.

11\leq article length 106\leq10^6.

NOIP 2011 Junior, Problem 2.

Translated by ChatGPT 5