luogu P6565 [NOI Online #3 入门组]最急救助
题面传送门
没啥好说的,模拟即可。
#include<cstdio>
#include<iostream>
#include<cstring>
#define max(a,b) ((a)>(b)?(a):(b))
using namespace std;
int n,m,k,ans,tot,pus,num[139],h[139];
char s[139][139],a[539];
int main(){
// freopen("save.in","r",stdin);
// freopen("save.out","w",stdout);
register int i,j;
scanf("%d",&n);
for(i=1;i<=n;i++){
cin>>s[i];
cin>>a+1;
m=strlen(a+1);
for(j=3;j<=m;j++){
if(a[j]=='s'&&a[j-1]=='o'&&a[j-2]=='s') h[i]++;
}
ans=max(ans,h[i]);
}
for(i=1;i<=n;i++){
if(h[i]==ans) printf("%s ",s[i]);
}
printf("\n%d",ans);
}