AcWing 5556. 牛的语言学
原题链接
中等
作者:
最后五分钟
,
2024-03-17 02:04:48
,
所有人可见
,
阅读 45
#include<bits/stdc++.h>
#define LL long long
#define x first
#define y second
#define de(x) cout<<#x<<" = "<<x<<" "
#define deg(x) cout<<#x<<" = "<<x<<endl
using namespace std;
const int N=1e4+10;
typedef pair<int,int> PII;
string s;
int f[N];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>s;
int n=s.size();
f[n-1]=1;
set<string> res;
for(int i=n-2;i>=4;i--)
for(int j=2;j<=3;j++)
{
if(f[i+j])
{
string a=s.substr(i+1,j);
string b=s.substr(i+j+1,j);
if(a!=b||f[i+5])
{
f[i]=1;
res.insert(a);
}
}
}
cout<<res.size()<<endl;
for(auto &it:res)
cout<<it<<endl;
return 0;
}