#9TLE
查看原帖
#9TLE
376908
juzi75楼主2020/10/4 21:51
#include<bits/stdc++.h>
using namespace std;
string word,test;
char ltos(char* t){
	if(*t>='A'&&*t<='Z') *t=(char)(*t+('a'-'A'));
}
int main(){
	int t,first,flag=1,k1,k2,cnt=0;
	getline(cin,word);
	getline(cin,test);
	word=" "+word+" ";
	test=" "+test+" ";
	k1=word.size();
	k2=test.size();
	for(int i=0;i<k1;i++){
		ltos(&word[i]);
	}
	for(int i=0;i<k2;i++){
		ltos(&test[i]);
	}
	while(1){
		t=test.find(word);
		if(t==-1){
			break;
		}
		if(flag){
			first=t;
			flag=0;
		}
		cnt++;
		test.erase(t+1,2);
	}
	if(cnt==0) cout<<-1;
	else cout<<cnt<<" "<<first;
	return 0;
}
2020/10/4 21:51
加载中...