#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
struct news{
string tp,tim,s[55];
int cnt;
}a[10005];
struct ac{
string s;
int sum;
}se[10005];
bool cmp(const ac &a,const ac &b)
{
if(a.sum==b.sum)
{
return a.s<b.s;
}
return a.sum>b.sum;
}
int n,m,k,nn,wh,mx;
string lasts,sss[10005];
map<string,bool>inq;
map<string,bool>inqq;
map<string,int>ans;
map<string,int>num;
queue<int>q[10005];
int main()
{
string s0;
while(1)
{
n++;
getline(cin,s0);
a[n].tp=s0;
cin>>a[n].tim;
while(getline(cin,s0))
{
if(s0=="------"||s0=="######")
break;
int cnt=0,last=0;
for(int i=0;i<s0.size();i++)
{
if(s0[i]==','||s0[i]=='.'||s0[i]=='?'||s0[i]=='!'||s0[i]==':')
s0[i]=' ';
if(s0[i]>='A'&&s0[i]<='Z')
s0[i]=s0[i]-'A'+'a';
}
s0=s0+' ';
for(int i=0;i<s0.size();i++)
{
if(s0[i]!=' ')
{
for(int j=i+1;j<s0.size();j++)
{
if(s0[j]==' ')
{
a[n].s[++a[n].cnt]=s0.substr(i,j-i);
last=100000;
i=j;
break;
}
}
}
}
if(last<s0.size()&&s0[last]!=' ')
a[n].s[++a[n].cnt]=s0.substr(last,s0.size()-last+1);
}
if(s0=="######")
break;
}
cin>>m>>k;
for(int i=1;i<=m;i++)
{
cin>>s0;
for(int j=0;j<s0.size();j++)
if(s0[j]>='A'&&s0[j]<='Z')
s0[j]=s0[j]-'A'+'a';
inq[s0]=1;
num[s0]=i;
sss[i]=s0;
}
for(int i=1;i<=n;i++)
{
sort(a[i].s+1,a[i].s+1+a[i].cnt);
for(int j=1;j<=a[i].cnt;j++)
{
if(a[i].s[j]!=a[i].s[j-1])
{
if(inq[a[i].s[j]])
{//cout<<a[i].s[j]<<' ';
ans[a[i].s[j]]++;
q[num[a[i].s[j]]].push(i);
inqq[a[i].s[j]]=1;
}
}
}
}
map<string,int>::iterator it;
for(it=ans.begin();it!=ans.end();it++)
{
if(it->second>=k)
{
se[++nn].s=it->first;
se[nn].sum=it->second;
}
else{
if(it->second>mx||it->second==mx&&it->first<lasts)
{
lasts=it->first;
mx=it->second;
wh=num[it->first];
}
}
}
if(k==0)
{
for(int i=1;i<=m;i++)
if(!inqq[sss[i]])
se[++nn].s=sss[i];
}
if(nn)
{
sort(se+1,se+1+nn,cmp);
for(int i=1;i<=nn;i++)
cout<<se[i].s<<':'<<se[i].sum<<endl;
wh=num[se[1].s];
}
else{
cout<<"None!"<<endl;
}
while(!q[wh].empty())
{
int j=q[wh].front();
q[wh].pop();
cout<<a[j].tp<<'/'<<a[j].tim<<endl;
}
return 0;
}
11-17
1622
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
08-26
1572
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)