显示代码纯文本
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
int a,b,n,len,num,sum,i,j;
string Str,str;
vector<string>V;
map<string,int>M;
set<string>S;
bool cmp(string x,string y)
{
if(M[x]==M[y])
{
if(x.length()==y.length())
{
int l=x.length();
for(int ii=0;ii<l;ii++)if(x[ii]!=y[ii])
return x[ii]<y[ii];
}
else return x.length()<y.length();
}
return M[x]>M[y];
}
int Main()
{
freopen("contact.in","r",stdin);freopen("contact.out","w",stdout);
scanf("%d%d%d",&a,&b,&n);
while(cin>>Str)str+=Str;
len=str.length();
for(i=0;i<len;i++)for(j=a;j<=b;j++)if(i+j<=len)
{
string s=str.substr(i,j);
M[s]++;
if(!S.count(s))
{
S.insert(s);
V.push_back(s);
}
}
sort(V.begin(),V.end(),cmp);
for(i=0;i<V.size();i++)
{
if(i==0||M[V[i]]!=M[V[i-1]])
{
num=0;
sum++;
if(sum>n)break;
if(i)printf("\n");
printf("%d\n",M[V[i]]);
}
cout<<V[i]<<' ';
num++;
if(num==6)cout<<endl;
}
return 0;
}
int main(){;}
int syy=Main();