Cod sursa(job #1995639)

Utilizator MaligMamaliga cu smantana Malig Data 28 iunie 2017 18:10:43
Problema Potrivirea sirurilor Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.76 kb
#include <iostream>
#include <fstream>
#include <queue>
#include <string.h>
#include <string>

using namespace std;
ifstream in("strmatch.in");
ofstream out("strmatch.out");

#define ll long long
#define pb push_back
#define ui unsigned int
const int inf = 1e9 + 5;
const int NMax = 2e6 + 5;

int N,nrSol;
int sol[NMax];

int main() {
    string patt,str;
    in>>patt>>str;

    size_t idx = 0,
           mx = str.npos;
    while (true) {
        idx = str.find(patt,idx);

        if (idx == mx) {
            break;
        }

        sol[++nrSol] = idx++;
    };

    out<<nrSol<<'\n';
    nrSol = min(1000,nrSol);
    for (int i=1;i <= nrSol;++i) {
        out<<sol[i]<<' ';
    }

    in.close();out.close();
    return 0;
}