Cod sursa(job #2617300)

Utilizator pro119Manea Dumitru pro119 Data 21 mai 2020 13:28:25
Problema Potrivirea sirurilor Scor 80
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.67 kb
#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int mxN=1000001;
string a,b;
int main()
{
    ifstream cin("strmatch.in");
    ofstream cout("strmatch.out");
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>a>>b;
    vector <int> res;
    size_t poz = b.find(a);
    if (poz!=-1) res.push_back(poz);
    else return cout<<0,0;
    while(1){
        poz = b.find(a,poz+1);
        if (poz==-1) break;
        else {
            res.push_back(poz);
        }
    }

    cout<<res.size()<<"\n";
    int k=res.size();
    for (int i=0; i<min(1000,k); i++)
        cout<<res[i]<<" ";

    return 0;
}