Cod sursa(job #1510686)

Utilizator RazvanatorHilea Razvan Razvanator Data 25 octombrie 2015 15:10:45
Problema Aho-Corasick Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.43 kb
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <fstream>

using namespace std;

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

int main()
{
    char a[1000000],cuv[10000];
    int n;
    f>>a>>n;
    while (f>>cuv) {
        int i=0,s=0;
        while (i<strlen(a)) {
            if (strncmp(cuv,a+i,strlen(cuv))==0) s++;
            i++;
        }
        g<<s<<endl;
    }
}