Pagini recente » Cod sursa (job #800922) | Cod sursa (job #1596677) | Cod sursa (job #1153200) | Cod sursa (job #2030775) | Cod sursa (job #1512845)
#include <fstream>
#include <cstring>
#define nmx 2000002
#define nx 1002
using namespace std;
ifstream f("strmatch.in");
ofstream o("strmatch.out");
char a[nmx],b[nmx];
int af[nx],la,lb,pa,pb,st,q;
int main() {
f >> a >> b;
la = strlen(a);
lb = strlen(b);
while(pb < lb && af[0] < 1000) {
q = 0,st = pb;
pa = 0;
while(pa < la) {
if(not q && pa && b[pb] == a[0])
q = pb;
if(a[pa] != b[pb]) {
break;
}
++ pa;
++ pb;
}
if(pa == la) {
++ af[0];
if(af[0] <= 1000 )
af[af[0]] = st;
}
if(q)
pb = q;
else
++ pb;
}
o << af[0] << "\n";
af[0] = min(1000,af[0]);
for(int i = 1; i <= af[0]; ++i)
o << af[i] << " ";
return 0;
}