Cod sursa(job #1108635)
| Utilizator | Data | 15 februarie 2014 21:43:50 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <fstream>
#include <cstring>
using namespace std;
ifstream f ("strmatch.in");
ofstream g ("strmatch.out");
long i,nr=0,v[1001],p;
char x[2000001],y[2000001];
int nailed (long ind)
{ for (int j=0;j<strlen(x);j++)
if (x[j]!=y[ind+j])return 0;
return 1;
}
int main()
{ f>>x>>y;
for (i=0;i<strlen(y);i++)
{if (nailed(i)==1)
{nr++;if (nr<=1000){p++;v[p]=i;}else break;}}
g<<nr<<'\n';
for (i=1;i<=p;i++)g<<v[i]<<' ';
return 0;
}
