A. Doggo Recoloring

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Panic is rising in the committee for doggo standardization — the puppies of the new brood have been born multi-colored! In total there are 26 possible colors of puppies in the nature and they are denoted by letters from 'a' to 'z' inclusive.

The committee rules strictly prohibit even the smallest diversity between doggos and hence all the puppies should be of the same color. Thus Slava, the committee employee, has been assigned the task to recolor some puppies into other colors in order to eliminate the difference and make all the puppies have one common color.

Unfortunately, due to bureaucratic reasons and restricted budget, there's only one operation Slava can perform: he can choose a color xxsuch that there are currently at least two puppies of color xx and recolor all puppies of the color xx into some arbitrary color yy. Luckily, this operation can be applied multiple times (including zero).

For example, if the number of puppies is 77 and their colors are represented as the string "abababc", then in one operation Slava can get the results "zbzbzbc", "bbbbbbc", "aaaaaac", "acacacc" and others. However, if the current color sequence is "abababc", then he can't choose xx='c' right now, because currently only one puppy has the color 'c'.

Help Slava and the committee determine whether it is possible to standardize all the puppies, i.e. after Slava's operations all the puppies should have the same color.

Input

The first line contains a single integer nn (1≤n≤1051≤n≤105) — the number of puppies.

The second line contains a string ss of length nn consisting of lowercase Latin letters, where the ii-th symbol denotes the ii-th puppy's color.

Output

If it's possible to recolor all puppies into one color, print "Yes".

Otherwise print "No".

Output the answer without quotation signs.

Examples

input

Copy

6
aabddc

output

Copy

Yes

input

Copy

3
abc

output

Copy

No

input

Copy

3
jjj

output

Copy

Yes

Note

In the first example Slava can perform the following steps:

  1. take all puppies of color 'a' (a total of two) and recolor them into 'b';
  2. take all puppies of color 'd' (a total of two) and recolor them into 'c';
  3. take all puppies of color 'b' (three puppies for now) and recolor them into 'c'.

In the second example it's impossible to recolor any of the puppies.

In the third example all the puppies' colors are the same; thus there's no need to recolor anything.

只要有一个字母出现了两次就可以了

注意要特判n=1的时候

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define inf 0x3f3f3f3f
using namespace std; int n;
const int maxn = 1e5 + 5;
int puppy[30];
char s[maxn]; int main()
{
while(scanf("%d", &n) != EOF){
cin>>s;
memset(puppy, 0, sizeof(puppy));
bool flag = false;
for(int i = 0; i < strlen(s); i++){
puppy[s[i] - 'a']++;
if(puppy[s[i] - 'a'] >= 2){
flag = true;
break;
}
}
if(flag || n == 1){
printf("Yes\n");
}
else{
printf("No\n");
}
}
return 0;
}

codeforces#505--A Doggo Recoloring的更多相关文章

  1. 【Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) A】 Doggo Recoloring

    [链接] 我是链接,点我呀:) [题意] 你可以把出现次数大于1的颜色换成其他颜色. 问你最后能不能全都变成同一种颜色 [题解] 判断一下有没有出现次数大于1的就好. 有的话.显然可以一直用它变颜色. ...

  2. Codeforces 505 A Mr. Kitayuta's Gift【暴力】

    题意:给出一个字符串,可以向该字符串的任意位置插入一个字母使其变成回文串 因为字符串的长度小于10,枚举插入的字母,和要插入的位置,再判断是否已经满足回文串 #include<iostream& ...

  3. Codeforces #505(div1+div2) D Recovering BST

    题意:给你一个升序的数组,元素之间如果gcd不为1可以建边,让你判断是否可以建成一颗二叉搜索树. 解法:dp,首先建图,然后进行状态转移.因为如果点k左端与i相连,右端与k相连,则i和k可以相连,同时 ...

  4. Codeforces #505(div1+div2) C Plasticine zebra

    题意:给你一段字符串,可以选择任意多的位置,每个位置会反转两边的字符串,问交错的字符串最长是多长? 思路:找规律,仔细分析样例1.假设位置为 1 2 3 4 5 6 7 8 9,反转之后会发现答案是7 ...

  5. Codeforces #505(div1+div2) B Weakened Common Divisor

    题意:给你若干个数对,每个数对中可以选择一个个元素,问是否存在一种选择,使得这些数的GCD大于1? 思路:可以把每个数对的元素乘起来,然后求gcd,这样可以直接把所有元素中可能的GCD求出来,从小到大 ...

  6. 【CF1025A】Doggo Recoloring(签到)

    题意:给定一个长度为 n 的小写字母串.可以将出现次数大于等于2的字母全部变成另一个小写字母,问最后能否将该小写字母串的所有字母变成同一个字母 n<=1e5 思路: #include<cs ...

  7. Codeforces Round #505

    Codeforces Round #505 A. Doggo Recoloring 题目描述:给定一个字符串,每次选择一个在字符串里面出现至少两次的字符,然后将这种字符变成那一种指定的字符,问最终这个 ...

  8. Codeforces Round #505 (Div 1 + Div 2) (A~D)

    目录 Codeforces 1025 A.Doggo Recoloring B.Weakened Common Divisor C.Plasticine zebra D.Recovering BST( ...

  9. Codeforces Round #505 (Div 1 + Div 2 Combined) Solution

    从这里开始 题目列表 瞎扯 Problem A Doggo Recoloring Problem B Weakened Common Divisor Problem C Plasticine zebr ...

随机推荐

  1. MySQL 插入数据时,中文乱码问题的解决

    当向 MySQL 数据库插入一条带有中文的数据形如 insert into employee values(null,'张三','female','1995-10-08','2015-11-12',' ...

  2. 桥接模式(bridge pattern)-------结构型模式

    桥接模式是一种对象结构型模式,其将抽象部分和它的实现部分分离,使它们都可以独立的变化,又称为柄体(Handle and Body)模式或接口(Interface)模式. 优点: 1.分离抽象接口及其实 ...

  3. 第五章 使用 SqlSession(MyBatis)

    在 MyBatis 中,你可以使用 SqlSessionFactory 来创建 SqlSession.一旦你获得一个 session 之后,你可以使用它来执行映射语句,提交或回滚连接,最后,当不再需要 ...

  4. MVC Razor与javascript混编(js中嵌入razor)

    其中的关键是输出js上的纯文本内容,让浏览器解析为其中的js代码 <script>    BUI.use('common/main',function(){        var conf ...

  5. jQuery操作属性和样式详解

    我们可以使用 javascript 中的getAttribute和setAttribute来操作元素的"元素属性".在 jQuery 中给你提供了attr()包装集函数, 能够同时 ...

  6. ubuntu 16.04 appstreamcli 问题

    http://blog.csdn.net/zhbpd/article/details/77508675

  7. java集合的中的集合关系实现或继承关系图

    放在这儿一目了然.

  8. [笔试题]黑板上写下50个数字,选两个黑板上数字a和b,在黑板写|b-a|,剩下的数字?

    在黑板上写下50个数字:1至50.在接下来的49轮操作中,每次做如下操作:选取两个黑板上的数字a和b,擦去,在黑板上写|b-a|.请问最后一次动作之后剩下的数字可能是什么?为什么?(不用写代码,不写原 ...

  9. Discuz 模板标签说明

    Discuz 模板标签说明 Discuz! 的模板采用近似 PHP 表达式的语法,基本都是可识别的HTML,但涉及到变量和动态内容时,基本形式下: <!-{ 代码内容 }-> 逻辑元素包围 ...

  10. 详解Integer.toString(int i)方法和String.valueOf(int i)方法

    通过查看String类的源码: public static String valueOf(int i) { return Integer.toString(i); } 我们可以看到,String.va ...