Cod sursa(job #2111817)
Utilizator | Data | 22 ianuarie 2018 18:32:46 | |
---|---|---|---|
Problema | Potrivirea sirurilor | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.71 kb |
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
char s1[2000004],s2[2000004];
int nr=0,v[2000004],k=1;
int main()
{
fin>>s1>>s2;
char c=s1[0];
char*p=strchr(s2,c);
while(p)
{
//fout<<p<<endl;
int ok=1;
for(int i=0;s1[i];i++)
{
if(s1[i]!=p[i])
{
ok=0;break;
}
}
if(ok==1)
{
nr++;
v[k]=strlen(s2)-strlen(p);
k++;
}
p=strchr(p+1,c);
}
k--;
fout<<nr<<'\n';
for(int i=1;i<=k;i++)
fout<<v[i]<<" ";
}