CodeForces 1025A Doggo Recoloring(思维水题)

题目链接:CodeForces 1025A Doggo Recoloring
在这里插入图片描述
在这里插入图片描述
一直是 Compilation error 编译错误,hash不能做数组名??

特判1 。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;
typedef long long ll;
const int maxn = 100010;
const int INF = 0x3f3f3f3f;
char a[maxn];
int cnt[30];	//int hash[30];

int main()
{
	int n;
	cin>>n;
	
	string s;
	cin>>s;
		
	if(n==1)	// 特判1 QAQ 
	{
		printf("Yes\n");
		return 0;
	}
	
	for(int i=0;i<n;i++)
		cnt[s[i]-'a']++;
		
	int flag = 0;
	for(int i=0;i<26;i++)
	{
		if(cnt[i]>=2)
		{
			flag = 1;
			break;
		}
	}
	
	if(flag == 1)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_42815188/article/details/89814443