Cod sursa(job #3037563)

Utilizator rxdgxnGantoi Radu rxdgxn Data 25 martie 2023 19:53:55
Problema Potrivirea sirurilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.47 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
using namespace std;

#define MAX 2000000
char a[MAX], b[MAX];
int t = 0;
vector<int> ap;

ifstream f("strmatch.in");
ofstream g("strmatch.out");


int main() {

    f >> a >> b;
    auto s = strstr(b, a);
    while (s) {
        ap.push_back(s - b);
        t++;
        s = strstr(s + 1, a);
    }
    g << t << endl;
    for (auto x : ap) g << x << " ";

    return 0;
}