为啥过不了
查看原帖
为啥过不了
298692
Rn_Lamsuly楼主2020/5/24 18:40

我朋友sxh说有坑

我硬是没看出来,所以我就只有60pts

#include<bits/stdc++.h>
using namespace std;
struct Node
{
	string name,helpsay;int sum;
}inf[105];
inline bool cmp(Node x,Node y)
{
	return (x.sum>y.sum);
}
inline int cnt(string s)
{
	int sum=0;
	int l=s.size();
	for(int i=0;i<=l-3;i++)
	{
		if(s[i]=='s'&&s[i+1]=='o'&&s[i+2]=='s')sum++;
	}
	return sum;
}
int main()
{
	//freopen("save.in","r",stdin);
	//freopen("save.out","w",stdout);
	int n;
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)
	{
		cin>>inf[i].name;
		cin>>inf[i].helpsay;
	}
	for(register int i=1;i<=n;i++)
	{
		inf[i].sum=cnt(inf[i].helpsay);
	}
	sort(inf+1,inf+n+1,cmp);
	for(register int i=1;inf[i].sum==inf[1].sum;i++)
	{
		cout<<inf[i].name<<' ';
	}
	cout<<endl<<inf[1].sum;
	return 0;
}
2020/5/24 18:40
加载中...