Cod sursa(job #104281)

Utilizator SpiriSpiridon Alexandru Spiri Data 16 noiembrie 2007 00:32:41
Problema Abc2 Scor 0
Compilator cpp Status done
Runda Happy Coding 2007 Marime 0.79 kb
#include <fstream>
#include <map>
#include <vector>
using namespace std;

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

string p, t;
int n, m;
int rez;
map<string,int> mp;

void Kmp();
void Prefix();

int main()
{
    fin >> t;
    n = t.size();
    
    int nr = 0;
    while ( fin >> p )
    {
          nr++;
          if ( nr == 1 )
          {
               for ( int i = 0; i < n-p.size(); i++ )
               {
                   string k(t.begin() + i,t.begin()+i+p.size());
                   mp[k] = 1;
               }
          }
          if ( mp[p] == 1 && mp[p] != 2 ) 
          {
               mp[p] = 2;
               rez++;
          }
    }
    
    fout << rez;
    
    fout.close();
    fin.close();
    
    return 0;
}