Cod sursa(job #1914882)

Utilizator tanasaradutanasaradu tanasaradu Data 8 martie 2017 18:49:46
Problema Potrivirea sirurilor Scor 80
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <bits/stdc++.h>
#define nmax 2000005
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
char a[nmax],b[nmax],*p;
int sol[nmax];
int n;
int main()
{
    int i;
    fin>>a>>b;
    p=strstr(b,a);
    while(p)
    {
        sol[++n]=(p-b);
        p++;
        p=strstr(p,a);
    }
    fout<<n<<"\n";
     n=min(n,1000);
    for(i=1;i<=n;i++)
        fout<<sol[i]<<" ";
    return 0;
}