Cod sursa(job #2865230)

Utilizator newagear2Dragan Iulian newagear2 Data 8 martie 2022 17:15:21
Problema Potrivirea sirurilor Scor 16
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.58 kb
#include <fstream>
#include <string>
#include <vector>
using namespace std;
ifstream cin("strmatch.in");
ofstream cout("strmatch.out");
string a, b;
int depth = 0;
vector<int> match;
int main()
{
    cin>>a>>b;
    for(int i=0;i<b.length();i++){
        if(a[depth] == b[i]){
            depth++;
            if(depth == a.length()){
                match.push_back(i - depth + 1);
                i-=depth-1;
                depth = 0;
            }
        }
        else depth =0;
    }
    cout<<match.size()<<endl;
    for(auto it:match){
        cout<<it<<" ";
    }
    

    return 0;
}