球猪
查看原帖
球猪
379113
dtrthg楼主2022/1/27 20:56

思路:输名字时顺便把名字标记了,下标用字符串中字符的ASCII码之和,等点明时判断下就行了。

但只有40分qwq(没超时)

记录

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
const int Maxn=1e5+10;
bool flag[Maxn],vis[Maxn];
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		string x;cin>>x;
		int len=x.size(),cnt=0;
		for(int j=0;j<len;j++)
		{
			cnt+=int(x[j]);
		}
		flag[cnt]=true;
	}
	int m;scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		string x;cin>>x;
		int len=x.size(),cnt=0;
		for(int j=0;j<len;j++)
		{
			cnt+=int(x[j]);
		}
		if(flag[cnt]==false) printf("WRONG\n");
		else if(vis[cnt]==true) printf("REPEAT\n");
		else
		{
			printf("OK\n");
			vis[cnt]=true;
		}
	}
	return 0;
}
2022/1/27 20:56
加载中...