Pagini recente » Cod sursa (job #983825) | Cod sursa (job #2041453) | Cod sursa (job #1825703) | Cod sursa (job #1705110) | Cod sursa (job #2161272)
#include <bits/stdc++.h>
using namespace std;
struct trie{
trie* f[52];
trie(){
memset(f, 0, sizeof(f));
}
};
trie* rad = new trie;
int sol = 1, n, m;
char c[105];
int main()
{
ifstream fin ("dictree.in");
ofstream fout ("dictree.out");
fin >> n;
for (int i = 1; i <= n; ++i){
fin >> c;
m = strlen(c);
trie *t = rad;
for (int j = 0; j < m; ++j){
int q;
if(c[j] >= 'a' && c[j] <= 'z')
q = c[j]-'a'+27;
else q = c[j]-'A';
if(t->f[q] == NULL){
t->f[q] = new trie;
++sol;
}
t = t->f[q];
}
}
fout << sol << "\n";
return 0;
}