Cod sursa(job #3209344)

Utilizator Razvan23Razvan Mosanu Razvan23 Data 2 martie 2024 11:40:11
Problema Potrivirea sirurilor Scor 80
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.63 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];
int n, k, l;

int main()
{
    ios_base :: sync_with_stdio(0);
    fin.tie(0);
    fout.tie(0);
    int i, j;
    fin >> v;
    fin >> s;
    fin.close();
    char *p = s;
    l = strlen(s);
    while((p = strstr(p, v)) != NULL)
    {
        if(k < 1000) a[++k] = l - strlen(p);
        else k++;
        p++;
    }
    fout << k << "\n";
    for(j=1; j<=min(k, 1000); j++)
        fout << a[j] << " ";
    fout.close();
    return 0;
}