Cod sursa(job #2413321)

Utilizator LittleWhoFeraru Mihail LittleWho Data 23 aprilie 2019 12:07:03
Problema Potrivirea sirurilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.8 kb
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef unsigned char uchar;
const int nmax = 101;

int main() {
    freopen("strmatch.in", "r", stdin);
    freopen("strmatch.out", "w", stdout);

    int sol[1001];
    int n = 0;
    string A;
    string B;
    getline(cin, A);
    getline(cin, B);
    regex re("(?=(" + A + ")).");

    std::sregex_iterator next(B.begin(), B.end(), re);
    std::sregex_iterator end;
    while (next != end) {
        std::smatch match = *next;
        if (n < 1000) sol[n] = match.position();
        n++;
        next++;
    }
    printf("%d\n", n);
    for (int i = 0; i < n && i < 1000; i++) {
        printf("%d ", sol[i]);
    }
    puts("");

    return 0;
}