Cod sursa(job #105936)

Utilizator tudalexTudorica Constantin Alexandru tudalex Data 18 noiembrie 2007 09:39:33
Problema Abc2 Scor 0
Compilator cpp Status done
Runda Happy Coding 2007 Marime 0.72 kb
#include <stdio.h>
#include <string.h>
#include <string>
#include <map>
#include <hash_map>

using namespace std;

/*struct eqstr
{
  bool operator()(const char* s1, const char* s2) const
  {
    return strcmp(s1, s2) == 0;
  }
};

string temp;
*/
hash_map<const char*, int, hash<const char*>, eqstr> cuv;
int main()
{
	freopen("abc2.in","r",stdin);
	freopen("abc2.out","w",stdout);
	gets(s);
	while (scanf("%s",&a[++i])>0)
	{
		l = strlen(a[i]);
		cuv[a[i]] = 1;
		if (l>lmax) lmax = l;
	}
	
	n = i;
	for (i = 0; a[i] != '\0'; ++ i)
	{
		for (j = 0; j < lmax && a[j+i] != '\0'; ++ j)
		{
			temp.clear();
			temp.push_back(a[j+i]);
			if (cuv[temp])
				++sol;
		}
	}
	printf("%d\n", sol);

}