Cod sursa(job #2457984)
| Utilizator | Data | 19 septembrie 2019 11:14:02 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 18 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.67 kb |
#include <fstream>
#include <vector>
using namespace std;
string a, b;
ifstream cin("strmatch.in");
ofstream cout("strmatch.out");
long long int sub = 0;
vector<int> pos;
int main(){
cin>>a>>b;
for(int x = 0, y = 0, l = b.size(), sz = a.size();x<l;x++){
if(b[x] == a[y]){
y++;
if(y == sz){
sub++;
y = 0;
if(pos.size() < 1000)
pos.push_back(x - sz + 1);
}else continue;
}
if(b[x] == a[0]){
y = 1;
}else y = 0;
}
cout<<sub<<'\n';
for(int x : pos){
cout<<x<<' ';
}
return 0;
}
