Cod sursa(job #1396975)
| Utilizator | Data | 23 martie 2015 10:34:51 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.64 kb |
#include <iostream>
#include <fstream>
#include <cstring>
#define M 2000001
using namespace std;
char A[M],B[M];
char *p;
int main()
{
int na,nb,i,s[500000],k=0;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
f.getline(A,M);
f.getline(B,M);
na=strlen(A);
nb=strlen(B);
if(na>nb)
{
g<<0;
return 0;
}
else
{
int poz;
p=strstr(B,A);
while(p)
{
poz=strlen(B)-strlen(p);
s[k++]=poz;
p=strstr(B+poz+1,A);
}
}
g<<k<<"\n";
for(i=0;i<k;i++)
g<<s[i]<<" ";
}
