代码如下:
#include <iostream>
#include <string>
using namespace std;
string a, b, bs[2001];
int ans = 0, firstPos, lena, lenb, lastPos = 0, bst = 0, last[2001];
int main(){
getline(cin, a);
getline(cin, b);
lena = a.length();
lenb = b.length();
for(int i = 0; i < lena; i++){
if(a[i] < 'a'){
a[i] += ' ';
}
}
for(int i = 0; i < lenb; i++){
if(b[i] < 'a' && b[i] != ' '){
}
}
for(int i = 0; i < lenb; i++){
if(b[i] == ' '){
bst++;
bs[bst] = b.substr(lastPos, i - lastPos);
last[bst] = i;
lastPos = i + 1;
}
}
bst++;
bs[bst] = b.substr(lastPos, lena - lastPos);
for(int i = 1; i <= bst; i++){
if(a == bs[i]){
ans++;
if(ans == 1){
firstPos = last[i - 1];
}
}
}
if(ans > 0){
cout << ans << " " << firstPos << endl;
} else {
cout << "-1" << endl;
}
return 0;
}