暴力建trie
#include#include #include const int maxn = 5000000;char ch[3000];int son[maxn][2],sz[maxn],tot=1,n;inline void ins(const char*ch){ int rt=1; for(;*ch;++ch){ int&x=son[rt][*ch-48]; if(!x)x=++tot; ++sz[rt=x]; }}inline void dfs(int rt){ if(sz[rt]>1)std::cout << sz[rt] << '\n'; if(son[rt][0])dfs(son[rt][0]); if(son[rt][1])dfs(son[rt][1]);}int main(){ std::ios::sync_with_stdio(false),std::cin.tie(0); std::cin >> n; std::cin >> ch; for(int i=0;i