Cod sursa(job #1355037)
Utilizator | Data | 22 februarie 2015 12:25:17 | |
---|---|---|---|
Problema | Potrivirea sirurilor | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.55 kb |
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
char a[2000002],b[2000002],n;
std::vector<int> poz;
int main()
{
freopen("strmatch.in","r",stdin);
freopen("strmatch.out","w",stdout);
scanf("%s %s",&a,&b);
n = 0;
while(strstr(b,a))
{
poz.push_back( n + strlen(b) - strlen(strstr(b,a)) );
n = n + 1 + strlen(b) - strlen(strstr(b,a));
strcpy(b,strstr(b,a)+1);
}
printf("%d\n",poz.size());
for(int i=0;i<poz.size();++i)printf("%d ",poz[i]);
return 0;
}