我在next[p][s[i]a]next[p][s[i]-'a']假如这个是00就是进入ifif判断了,那么肯定是一个新出现的字符串,生成一个变量初始为falsefalse,如果进入ifif判断就改成truetrue,说明多了个新的串呀,感觉没啥毛病。

void insert(char *s) {
  int p = 0;
  bool is = false;
  for (int i = 0; s[i] != '\0'; ++i) {
    if (!next[p][s[i] - 'a']) is = true, next[p][s[i] - 'a'] = ++idx;
    p = next[p][s[i] - 'a'];
  }
  if (is) ++cnt;
}

0 comments

No comments so far...

Information

ID
180
Time
1000ms
Memory
256MiB
Difficulty
3
Tags
# Submissions
839
Accepted
131
Uploaded By