Violence ideas:
Enumeration value substring violence, inserted in the trie, lexicographical ordering of the output end is greater than 1
Time complexity: n- . 3
The results: TLE 0 points
. . . Very awkward a little left
Positive Solutions of ideas: After observation that can enumerate only the suffix, when the output value of the sum of statistics
code
`` `Cpp
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e7;
int n,cnt;
string ss;
struct node{
int sum,end,son[2];
} Sorts [MAXN];
void insert(string s)
{
int now=0,x;
for(int i=0;i<s.length();i++){
x=trie[now].son[s[i]-'0'];
if(x==0){
x=trie[now].son[s[i]-'0']=++cnt;
}
trie[x].sum++;
now=x;
}
}
void build()
{
for(int i=0;i<n;i++){
insert(ss.substr(i,n-i));
}
}
void query(int now)
{
if(trie[now].sum>1){
cout<<trie[now].sum<<endl;
}
if(trie[now].son[0]){
query(trie[now].son[0]);
}
if(trie[now].son[1]){
query(trie[now].son[1]);
}
}
int main ()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
cin>>n>>ss;
build();
query(0);
return 0;
}
```
It is heard positive solution SA
But I will not die too weak