hiho Week 4 register

Ended

Participants:617

Verdict:Accepted
Score:100 / 100
Submitted:2014-08-01 21:08:09

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<cstring>
#include<string>
#include<queue>
using namespace std;
struct Trie{
    int flag;
    struct Trie *next[26];
    struct Trie *suffix;
    Trie(){
        flag=0;
        memset(next,NULL,sizeof(next));
        suffix=NULL;
    }
};
void build(Trie *root, string &s){
    Trie *cur=root;
    int len=s.length();
    for(int i=0;i<len;++i){
        int id=s[i]-'a';
        if(!cur->next[id]){
            Trie *nn=new Trie();
            cur->next[id]=nn;
        }
        cur=cur->next[id];
    }
    cur->flag=1;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX