Cod sursa(job #3136951)

Utilizator sebuxSebastian sebux Data 9 iunie 2023 15:58:26
Problema Potrivirea sirurilor Scor 80
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.03 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");



int main()
{
    vector<int> r;
    string a, b;
    fin >> b >> a;
    for (auto it = a.begin(); it != a.end(); ++it)
    {
        bool ok = true;
        int nr = 0;
        for (auto jt = it, bt = b.begin(); jt != a.end() && bt != b.end(); ++jt, ++bt)
        {
            nr++;
            if (*jt != *bt)
            {
                ok = false;
                break;
            }
        }
        if (ok && nr == b.size())
            r.pb(it - a.begin());
    }
    fout<<r.size()<<'\n';
    int i = 0;
    for(let it = r.begin();it != r.end() && i < 1000;++it, ++i) fout<<*it<<' ';

    return 0;
}