退役后真的什么都忘了...
最好能指出思路或代码的问题所在,代码应该比较好理解吧。。。先全部大写然后分割单词进行处理。
代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
string s,s1,temp;
int tot,ans;
bool flag=true;
inline bool check(string a,string b){
if(a.size()!=b.size()) return false;
for(int i=0;i<a.size();i++){
if(a[i]!=b[i]) return false;
}
return true;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
getline(cin,s,'\n');
getline(cin,s1,'\n');
s1=s1+" ";
transform(s.begin(),s.end(),s.begin(),::toupper);
transform(s1.begin(),s1.end(),s1.begin(),::toupper);
for(int i=0;i<s1.size();i++){
if(s1[i]<='A'||s1[i]>='Z'){
//cout<<i<<' '<<temp.size()<<endl;
if(check(temp,s)){
tot++;
if(flag){
flag=false;
ans=i-temp.size();
}
}
//cout<<temp<<endl;
temp="";
}
else temp+=s1[i];
}
if(tot==0) cout<<-1;
else cout<<tot<<' '<<ans;
return 0;
}