Cod sursa(job #2485117)
| Utilizator | Data | 31 octombrie 2019 23:53:24 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 16 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.58 kb |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
ifstream fin("strmatch.in"); ofstream fout("strmatch.out");
string a, b;
int n; vector<int> c;
int main(){
fin>>a>>b;
if(b.length()<a.length()){fout<<0;}else{
for(int i=0; i<b.length(); i++){
if(i>b.length()-a.length()){break;}
for(int p=0; p<a.length(); p++){
if(a[p]!=b[i+p]){i=i+p; break;}
else{if(p==(a.length()-1)){n++; c.pb(i);}}
}
}
fout<<n<<endl;
for(int i=0; i<c.size(); i++){
fout<<c[i]<<' ';
}
}
return 0;
}