Cod sursa(job #1757464)

Utilizator iordache.bogdanIordache Ioan-Bogdan iordache.bogdan Data 15 septembrie 2016 09:08:23
Problema Potrivirea sirurilor Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.58 kb
#include <fstream>
#include <vector>
#include <string>

using namespace std;

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

int main() {

    string a, b;
    fin >> a >> b;

    int ans = 0;
    vector<size_t> positions;

    for (size_t pos = b.find(a, 0); pos != string::npos; pos = b.find(a, pos + 1)) {

        ans++;
        if (ans <= 1000)
            positions.push_back(pos);

    }

    fout << ans << '\n';
    for (auto pos : positions)
        fout << pos << ' ';
    fout << '\n';

    return 0;

}

//Trust me, I'm the Doctor!