Cod sursa(job #1971000)

Utilizator robertro1Benedek Robert George robertro1 Data 19 aprilie 2017 19:11:47
Problema Potrivirea sirurilor Scor 26
Compilator cpp Status done
Runda Arhiva educationala Marime 0.93 kb
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ifstream f("strmatch.in");
    ofstream g("strmatch.out");
    string a;
    string b;
    f>>a>>b;
    vector<int> v;
    cout<<b.size()<<a.size();
   long long rep=0, gasit;
    for(int i=0; i<b.size()-(a.size()-1); ++i)
    {
        if(b[i]==a[0])
            {
                gasit=1;
                for(int j=1; j<a.size(); ++j)
                {
                    if(b[i+j]!=a[j])
                        {
                            gasit=0;
                            break;
                        }
                }
                if(gasit==1)
                    {
                        rep++;
                        v.push_back(i);
                    }
            }
    }
    g<<rep<<'\n';
    sort(v.begin(),v.end());
    if(rep>=1000) rep=1000;
    for(int i=0; i<=rep-1; i++)
        g<<v[i]<<" ";
    return 0;
}