Cod sursa(job #3135463)

Utilizator sebuxSebastian sebux Data 3 iunie 2023 12:42:24
Problema Potrivirea sirurilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.01 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;
string filename = "strmatch";
ifstream fin(filename + ".in");
ofstream fout(filename + ".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';
    for(let i : r) fout<<i<<' ';

    return 0;
}