https://www.luogu.com.cn/problem/P1308
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
static vector<string> g_inputList;
static vector<int> g_inputListIndex;
void getInput()
{
char ctmp;
int numOfInput = 0;
char strInput[11] = {0};
int index = 0;
while (1)
{
int isEof = scanf("%c", &ctmp);
if (isEof == EOF || '\n' == ctmp || ' ' == ctmp)
{
if (numOfInput > 0)
{
g_inputList.push_back(strInput);
g_inputListIndex.push_back(index-numOfInput);
memset(strInput, 0, sizeof(strInput));
numOfInput = 0;
}
if (isEof == EOF || '\n' == ctmp)
{
break;
}
}
else
{
if (ctmp >= 'A' && ctmp <= 'Z')
{
strInput[numOfInput] = ctmp + 0x20;
}
else
{
strInput[numOfInput] = ctmp;
}
numOfInput++;
}
index++;
}
}
int main()
{
string word;
getInput();
word = g_inputList[0];
g_inputList.clear();
g_inputListIndex.clear();
getInput();
int n = g_inputList.size();
int outputNum = 0;
int outputIndex = 0;
for (int i = 0; i < n; i++)
{
if (word == g_inputList[i])
{
if (0 == outputNum)
{
outputIndex = g_inputListIndex[i];
}
outputNum++;
}
}
if (outputNum)
{
cout << outputNum << ' ' << outputIndex << endl;
}
else
{
cout << "-1" << endl;
}
return 0;
}