Files
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

32 lines
706 B
C++

#include <bits/stdc++.h>
using namespace std;
string p, s;
void to_lower(string &s) {
for (auto &c : s) c = tolower(c);
}
int main() {
getline(cin, p);
getline(cin, s);
to_lower(p), to_lower(s);
int cnt = 0, k = -1;
for (int i = 0; i < s.size(); i++) {
if (s[i] == ' ') continue;
int j = i + 1;
while (j < s.size() && s[j] != ' ') j++; // 找到结束位置
if (p == s.substr(i, j - i)) { // 截取并判断是不是相等
cnt++;
if (k == -1) k = i;
}
i = j;
}
if (!cnt)
puts("-1");
else
cout << cnt << ' ' << k << endl;
return 0;
}