hiho Week 15 register

Ended

Participants:1653

Verdict:Time Limit Exceeded
Score:80 / 100
Submitted:2014-10-16 18:01:22

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 <string>
#include <map>
using namespace std;
//
class Node {
public:
    int id;
    Node* children[26];
    Node(int d) : id(d) {
        for (int i = 0; i < 26; ++i) {
            children[i] = NULL;
        }
    }
};
Node * findChild(Node *root, char c) {
    int idx;
    if (c >= 'A' && c <= 'Z')  idx = c - 'A';
    else                                   idx = c - 'a';
    return root->children[idx];
}
int findString(Node *root, string str) {
    Node *curNode = root;
    for (int j = 0; j < str.length(); ++j) {
        Node *p = findChild(curNode, str[j]);
        if (p == NULL) {
            return -1;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX