Cod sursa(job #105965)

Utilizator tudalexTudorica Constantin Alexandru tudalex Data 18 noiembrie 2007 10:16:36
Problema Abc2 Scor 0
Compilator cpp Status done
Runda Happy Coding 2007 Marime 0.62 kb
#include <stdio.h>
#include <string.h>
#include <string>
#include <set>

using namespace std;



set <string> cuv;
char s[10000100],
	 t[200];
string temp;
int i, l, lmax, j, n, sol, lt, d;
int main()
{
	freopen("abc2.in","r",stdin);
	freopen("abc2.out","w",stdout);
	gets(s);
	while (scanf("%s",t)>0)
	{
		l = strlen(t);
		temp = t;
		cuv.insert(temp);
		if (l>lmax) lmax = l;
	}
	
	n = i;
	for (i = 0; s[i] != '\0'; ++ i)
	{
		temp.clear();
		for (j = 0; j < lmax && s[j+i] != '\0'; ++ j)
		{
			temp.push_back(s[j+i]);
			if (cuv.find(temp)!=cuv.end())
				++sol;
		}
	}
	printf("%d\n", sol);
}