hiho Week 2 register

Ended

Participants:1624

Verdict:Accepted
Score:100 / 100
Submitted:2014-07-13 14:27:00

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
struct trie
{
    vector<trie *> child;
    int count;
    trie()
    {
        child.resize(26,NULL);
        count=1;
    }
};
void buildTrie(trie * root,char *a)
{
    int i=0;
    while(i<strlen(a))
    {
        int index=a[i]-'a';
        if(root->child[index]==NULL)
            root->child[index]=new trie();
        else
            root->child[index]->count++;
        root=root->child[index];
        i++;
    }
}
int preCount(trie * root,char *a)
{
    int i=0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX