#T687. 【NOIP2011-J2】统计单词数
【NOIP2011-J2】统计单词数
Description
A typical text editor has a word search function that can quickly locate specific words in a document, and some can even count the number of times a specific word appears in the document.
Now, please implement this functionality through programming. The specific requirements are: given a word, output its frequency of occurrence in the provided article and the position of its first occurrence. Note: when matching words, case is ignored, but an exact match is required. The given word must exactly match an independent word in the article (case-insensitive, see Sample 1). If the given word is only part of a word in the article, it does not count as a match (see Sample 2).
Input Format
The input consists of two 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
There is only one line of output. If the given word is found in the article, output two integers separated by a space: the number of times the word appears in the article and the position of its first occurrence (i.e., the position of the first letter of the word's first occurrence in the article, with positions starting from 0). If the word does not appear in the article, simply output the integer -1.
【Data Range】
1 ≤ Word length ≤ 10.
1 ≤ Article length ≤ 1,000,000.
Source
NOIP2011-J2