Cod sursa(job #2937617)

Utilizator ionut98Bejenariu Ionut Daniel ionut98 Data 10 noiembrie 2022 18:33:11
Problema Potrivirea sirurilor Scor 38
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.63 kb
#include <iostream>
#include <fstream>
#include <cstring>
#include<deque>

using namespace std;

ifstream fin("strmatch.in");
ofstream fout ("strmatch.out");

int main()
{
    deque<int> q;
    char a[2000001];
    char b[2000001];
    fin>>a>>b;
    char *x;
    x = strstr(b, a);
    int sum = 0, c = 0;
    while(x)
    {
        q.push_back(sum + strlen(b) - strlen(x));
        sum += strlen(b) - strlen(x) + 1;
        strcpy(b,x+1);
        x = strstr(b, a);
        c++;
    }
    fout << c << '\n';
    while(!q.empty())
    {
        fout<< q.front() << " ";
        q.pop_front();
    }
    return 0;
}