Cod sursa(job #3209342)

Utilizator Razvan23Razvan Mosanu Razvan23 Data 2 martie 2024 11:38:08
Problema Potrivirea sirurilor Scor 80
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.68 kb
#include <bits/stdc++.h>
using namespace std;

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

char s[2000005], v[2000005];
int a[1005], m;
int n, k, l;

int main()
{
    ios_base :: sync_with_stdio(0);
    fin.tie(0);
    fout.tie(0);
    int i, l, j;
    fin >> v;
    fin.get();
    fin >> s;
    int nr = 0;
    char *p = s;
    l = strlen(s);
    while((p = strstr(p, v)) != NULL)
    {

        if(k < 1000) a[++k] = l - strlen(p);
        else k++;
        nr++;
        p++;
    }
    fout << k << "\n";
    for(j=1; j<=min(k, 1000); j++)
        fout << a[j] << " ";
    fin.close();
    fout.close();
    return 0;
}