Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a group of b-s), but cccc is not since in each possible consequent partition letters in these two groups coincide.

You're given a string s. Check whether it can be split into two non-empty subsequences such that the strings formed by these subsequences are adorable. Here a subsequence is an arbitrary set of indexes of the string.

Input

The only line contains s (1 ≤ |s| ≤ 105) consisting of lowercase latin letters.

Output

Print «Yes» if the string can be split according to the criteria above or «No» otherwise.

Each letter can be printed in arbitrary case.

Examples
input
ababa
output
Yes
input
zzcxx
output
Yes
input
yeee
output
No

题意:如果能把一个字符串分成两份,每份都可以被分成只有相同字母的两块,并且这两块的字母不相同,那么输出yes,反之no。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define eps 0.00000001
#define pn printf("\n")
using namespace std;
typedef long long ll; const int maxn = 1e5+;
map <char,int> mp; int main()
{
char s[maxn];
gets(s);
int len = strlen(s);
for(int i=;i<len;i++)
mp[s[i]]++;
int fl = ;
for(map<char,int>::iterator it = mp.begin(); it!=mp.end(); it++)
if(it->second == )
fl++;
if(mp.size() > ) printf("No\n");
else if(mp.size() == && fl) printf("No\n");
else if(mp.size() == ) printf("No\n");
else if(mp.size() == fl && fl% == ) printf("No\n");
else printf("Yes\n"); }

Codeforces Round #471 (Div. 2)B. Not simply beatiful strings的更多相关文章

  1. Codeforces Round #471 (Div. 2) C. Sad powers

    首先可以前缀和 ans = solve(R) - solve(L-1) 对于solve(x) 1-x当中符合条件的数 分两种情况 3,5,7,9次方的数,注意这地方不能含有平方次 平方数 #inclu ...

  2. Codeforces Round #471 (Div. 2) F. Heaps(dp)

    题意 给定一棵以 \(1\) 号点为根的树.若满足以下条件,则认为节点 \(p\) 处有一个 \(k\) 叉高度为 \(m\) 的堆: 若 \(m = 1\) ,则 \(p\) 本身就是一个 \(k\ ...

  3. Codeforces Round #471 (Div. 2)A. Feed the cat

    After waking up at hh:mm, Andrew realised that he had forgotten to feed his only cat for yet another ...

  4. 字符串(后缀自动机):Codeforces Round #129 (Div. 1) E.Little Elephant and Strings

    E. Little Elephant and Strings time limit per test 3 seconds memory limit per test 256 megabytes inp ...

  5. Codeforces Round #272 (Div. 1) Problem C. Dreamoon and Strings

    C. Dreamoon and Strings time limit per test 1 second memory limit per test 256 megabytes input stand ...

  6. Codeforces Round #129 (Div. 1)E. Little Elephant and Strings

    题意:有n个串,询问每个串有多少子串在n个串中出现了至少k次. 题解:sam,每个节点开一个set维护该节点的字符串有哪几个串,启发式合并set,然后在sam上走一遍该串,对于每个可行的串,所有的fa ...

  7. Codeforces Round #179 (Div. 2) B. Yaroslav and Two Strings (容斥原理)

    题目链接 Description Yaroslav thinks that two strings s and w, consisting of digits and having length n  ...

  8. Codeforces Round #112 (Div. 2)

    Codeforces Round #112 (Div. 2) C. Another Problem on Strings 题意 给一个01字符串,求包含\(k\)个1的子串个数. 思路 统计字符1的位 ...

  9. Codeforces Round #296 (Div. 1) C. Data Center Drama 欧拉回路

    Codeforces Round #296 (Div. 1)C. Data Center Drama Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xx ...

随机推荐

  1. 暑假集训D14总结

    %dalao 今天dalao继续来讲课~讲的是一个叫kd树的奇怪东西= = 然而啥都没听懂 考试 今天多校联考,日常炸= = 照例打了前两道题的暴力(T1随便hash一下就水过了啊喂),然后开始推T3 ...

  2. 洛谷 P1560 [USACO5.2]蜗牛的旅行Snail Trails(不明原因的scanf错误)

    P1560 [USACO5.2]蜗牛的旅行Snail Trails 题目描述 萨丽·斯内尔(Sally Snail,蜗牛)喜欢在N x N 的棋盘上闲逛(1 < n <= 120). 她总 ...

  3. SVN提示被锁定的解决方法(转)

    1.(常用)出现这个问题后使用“清理”即"Clean up"功能,如果还不行,就直接到上一级目录,再执行“清理”,然后再“更新”. 2.(没试过)有时候如果看到某个包里面的文件夹没 ...

  4. 最简单的基于FFmpeg的移动端样例:IOS 推流器

    ===================================================== 最简单的基于FFmpeg的移动端样例系列文章列表: 最简单的基于FFmpeg的移动端样例:A ...

  5. uva 1555 Garland

    题意:有n个灯笼.第一个的高度是A,最后一个是B.灯笼的关系给出.并要求每一个灯笼的高度是非负数的.求最低的B 思路:推出公式:H[i]=2*H[i-1]+2-H[i-2],然后枚举H[2],在知道H ...

  6. PHP反射类的理解(代码篇)

    <?php/** * Created by PhpStorm. * User: * Date: 2017/6/12 * Time: 14:34 * 关于反射类的理解 */class Person ...

  7. bzoj4956: [Wf2017]Secret Chamber at Mount Rushmore

    F......loyd? 这范围也是..... 然而大了也不会.... #include<cstdio> #include<iostream> #include<cstr ...

  8. 【docker】python: can't open file 'helloworld.py': [Errno 13] Permission denied

    运行容器提示权限问题 docker run  -v $PWD/myapp:/usr/src/myapp  -w /usr/src/myapp python:3.5 python helloworld. ...

  9. cloudfoundry service broker 制作

    实验室这边需要制作service broker.从今天开始将精力投入其中.

  10. CSS Flexbox 弹性盒子模型

    CSS Flexbox 弹性盒子模型 设置元素样式为 display: flex 或 display: inline-flex, 让元素变成flex容器, 从而可以通过flex模式布局它的子元素. f ...