Cod sursa(job #2937613)

Utilizator bogdan.schiopBogdan Schiop bogdan.schiop Data 10 noiembrie 2022 18:28:12
Problema Potrivirea sirurilor Scor 38
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.66 kb
#include <iostream>
#include <fstream>
#include <cstring>
#include <deque>

using namespace std;

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

char a[2000001];
char b[2000001];

deque<int> q;
int c;

void rez()
{
    fin >> a >> b;
    char *x;
    int sum = 0;
    x = strstr(b, a);
    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++;
    }
}

int main()
{
    rez();
    fout << c << '\n';
    while(!q.empty())
    {
        fout << q.front() << ' ';
        q.pop_front();
    }
    return 0;
}