Cod sursa(job #3136950)

Utilizator sebuxSebastian sebux Data 9 iunie 2023 15:49:34
Problema Potrivirea sirurilor Scor 80
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.86 kb
#include <bits/stdc++.h>
#define optim ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define let auto
#define popcount __builtin_popcount
#define ctzll __builtin_ctzll
#define clzll __builtin_clzll

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



const int sze = 2e6;
char a[sze + 1];
char b[sze + 1];
int v[sze + 1];
int n = 0;
let main() -> int
{
    fin>>a>>b;
    int sb = strlen(b);
    int sa = strlen(a);
    
    for(int i = 0;i < sb;++i) {
        int j = i;
        while(b[j] == a[j - i] && j < sb){
            j++;
        }
        if(j - i == sa) v[++n] = i;
    }

    fout<<n<<'\n';
    n = min(n, 1000);
    for(int i = 1;i<=n;++i) fout<<v[i]<<' ';



    return 0;
}