Cod sursa(job #2391557)

Utilizator StormieStormie Stormie Data 28 martie 2019 22:54:22
Problema Potrivirea sirurilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.75 kb
#include <iostream>
#include <fstream>
#include <string.h>
#include <vector>
#define MAXIM 2000010
#define d 256
#define q 100007


using namespace std;

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

char A[MAXIM], B[MAXIM];
int hashA, hashB, power = 1, nrSol;
vector <int> G;

void printOccurrences(string txt, string pat)
{
    int found = txt.find(pat);
    while (found != string::npos) {
        nrSol++;
        if(nrSol <= 999) G.push_back(found);
        found = txt.find(pat, found + 1);
    }
}

int main()
{
    f >> A >> B;

    printOccurrences(B, A);

    g << nrSol << '\n';
    for(unsigned int i = 0; i < G.size(); i++)
        g << G[i] << ' ';

    f.close();
    g.close();

    return 0;
}