请帮我找出这段代码中的错误。我写了一个简单的程序,通过Aho-Corasick算法添加n个字符串来尝试,但它不能正常工作。输入字符串后它会崩溃。这段代码有什么问题?
#include <cstdlib>
#include <iostream>
#include <vector>
#define ALPHABET 26
using namespace std;
struct item
{
       int next[ALPHABET];
       int leaf;
       item()
       {
               for (int i = 0; i < ALPHABET; i++)
                       next[i] = -1;
               leaf = 0;
       }
};
vector <item> trie;
int add_string(string &s)
{
       int z = 0;
       item temp;
       for (int i = 0; i < s.length(); i++)
       {
              char c = s[i] - 'a';
              if (trie[z].next[c] == -1)
              {
                     trie[z].next[c] = trie.size();
                     trie.push_back(temp);}
                     z = trie[z].next[c];
              }
              trie[z].leaf = true;
       }
}
int main(int argc, char *argv[])
{
       int n;
       cin >> n;
       string s[n];
       for (int i = 0; i < n; i++)
              cin >> s[i];
       for (int i = 0; i < n; i++)
              add_string(s[i]);
       system("PAUSE");
       return EXIT_SUCCESS;
}