Pagini recente » Cod sursa (job #3255663) | Cod sursa (job #2386808) | Cod sursa (job #1467229) | Cod sursa (job #1003186) | Cod sursa (job #2865255)
#include <fstream>
#include <string>
#include <vector>
using namespace std;
ifstream cin("strmatch.in");
ofstream cout("strmatch.out");
string a, b;
int depth = 0;
vector<int> match;
int main()
{
cin>>a>>b;
for(int i=0;i<b.length();i++){
if(a[depth] == b[i]){
depth++;
if(depth == a.length()){
match.push_back(i - depth + 1);
i-=depth-1;
depth = 0;
}
}
else depth =0;
}
cout<<match.size()<<endl;
if(match.size()>1000)match.erase(match.begin()+1000, match.end());
for(auto it:match){
cout<<it<<" ";
}
return 0;
}