Cod sursa(job #2617288)

Utilizator pro119Manea Dumitru pro119 Data 21 mai 2020 13:13:29
Problema Potrivirea sirurilor Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.63 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";
    for (int i=0; i<min(res.size(),1000); i++)
        cout<<res[i]<<" ";

    return 0;
}