本人幼儿园小班,刚学字典树,CE 不知道该怎么解决,求条玄关。
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5;
int trie[N][26], tot = 1;
bool ends[N];
void insert(char* str) {
int len = strlen(str), p = 1;
for (int k = 0; k < len; k++) {
int ch = str[k] - 'a';
if(trie[p][ch] == 0) trie[p][ch] = ++tot;
p = trie[p][ch];
}
ends[p] = true;
}
bool serch(char* str) {
int len = strlen(str), p = 1;
for (int k = 0; k < len; k++) {
p = trie[p][str[k] - 'a'];
if(p == 0) return false;
}
return ends[p];
}
signed main() {
return 0;
}