Cod sursa(job #2617304)

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

string a,b;
vector <int> res;
int k;
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;
    int k=0;
    size_t poz = b.find(a);
    if (poz!=-1) {
        res.push_back(poz);
        k++;
    }
    while(1){
        poz = b.find(a,poz+1);
        if (poz==-1) break;
        else {
            res.push_back(poz);
            k++;
        }
    }

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

    return 0;
}