Cod sursa(job #2865229)
| Utilizator | Data | 8 martie 2022 17:14:42 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.58 kb |
#include <fstream>
#include <string>
#include <vector>
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("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;
for(auto it:match){
cout<<it<<" ";
}
return 0;
}
