版本比较
字典树
正文
增加 5 行删除 5 行
71 行未改动7273747576767778787980818254 行未改动13713813914014114114214314414562 行未改动2082092102112122122132142152163 行未改动220221222223224224225226227228126 行未改动全部展开71 行未改动 cin>>k; cout<<query(k)<<"\n"; } }
return 0;} }```
T2:由于cnt[u],统计的是经过u的所有字符串,所以在查询时,如果发现有字符串是以T为前缀,并且存在,答案加1.
54 行未改动 cin>>k; cout<<query(k)<<"\n"; } return 0;} }```
T3:
62 行未改动 } cout<<query(s)<<"\n"; } return 0;} }```
T4:
3 行未改动
```cpp#include <bits/stdc++.h>using namespace std;const int maxn = 3e5 + 7; const int maxn = 3e5 + 7;int n;int node[maxn][26];int tot;int exist[maxn];126 行未改动全部展开