Codeforces Round #471 (Div. 2)B. Not simply beatiful strings
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.
The only line contains s (1 ≤ |s| ≤ 105) consisting of lowercase latin letters.
Print «Yes» if the string can be split according to the criteria above or «No» otherwise.
Each letter can be printed in arbitrary case.
ababa
Yes
zzcxx
Yes
yeee
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的更多相关文章
- Codeforces Round #471 (Div. 2) C. Sad powers
首先可以前缀和 ans = solve(R) - solve(L-1) 对于solve(x) 1-x当中符合条件的数 分两种情况 3,5,7,9次方的数,注意这地方不能含有平方次 平方数 #inclu ...
- Codeforces Round #471 (Div. 2) F. Heaps(dp)
题意 给定一棵以 \(1\) 号点为根的树.若满足以下条件,则认为节点 \(p\) 处有一个 \(k\) 叉高度为 \(m\) 的堆: 若 \(m = 1\) ,则 \(p\) 本身就是一个 \(k\ ...
- 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 ...
- 字符串(后缀自动机):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 ...
- 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 ...
- Codeforces Round #129 (Div. 1)E. Little Elephant and Strings
题意:有n个串,询问每个串有多少子串在n个串中出现了至少k次. 题解:sam,每个节点开一个set维护该节点的字符串有哪几个串,启发式合并set,然后在sam上走一遍该串,对于每个可行的串,所有的fa ...
- 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 ...
- Codeforces Round #112 (Div. 2)
Codeforces Round #112 (Div. 2) C. Another Problem on Strings 题意 给一个01字符串,求包含\(k\)个1的子串个数. 思路 统计字符1的位 ...
- 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 ...
随机推荐
- Spring Cloud-hystrix Feign(九)
前面使用ribbon拦截RestTemplate 实现服务的负载均衡 使用Hystrix进行熔断降级请求缓存 用原生的方式 将会有大量的模板代码,feigin就是rabbon和Histrix的整合 ...
- 浅析IT系统监控方法和应用
浅析IT系统监控方法和应用 http://blog.csdn.net/zhangman117/article/details/35549363
- gdb的follow-fork-mode使用以及多线程操作
对于多线程,如果希望让其他线程不执行,只有调试线程执行,使用 set scheduler-locking [on|off|step]
- 杭电(hdu)ACM 1010 Tempter of the Bone
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- Android解决使用findViewById时须要对返回值进行类型转换问题的辅助类
在我们的开发工作时,findViewById可能是用得最多的函数之中的一个.但它特别讨厌的地方就是我们常常须要对返回的view进行类型转换,输入麻烦.代码丑陋,比如曾经我们在Activity中找一些子 ...
- C++数组类模板
* 作为数组类模板,肯定没有vector做得好,可是普通的数组有1个优点就是能直接操作内存.vector在这方面就不是非常方便了. 网上尽管也有数组类模板.多维的设计基本上都不是非常好.我这个类模板多 ...
- luogu2761 软件补丁问题 状态压缩最短路径
关键词:状态压缩 最短路径 想不出快速办法,就先考虑考虑暴力.枚举每一种错误分布的情况,然后通过可用的补丁转化为另多种情况,这些情况又转化为更多种情况……我们可以用图来表示这种关系! 状态压缩:每个错 ...
- 2017-3-13 leetcode 4 11 15
ji那天居然早起了,惊呆我了,眼睛有点儿疼,一直流泪....继续保持 ========================================================== leetco ...
- EOJ 1113 装箱问题
有一个箱子容量为 V (正整数,0≤V≤20000),同时有 n 个物品(0<n≤30),每个物品有一个体积(正整数).要求从 n 个物品中,任取若干个装入箱内,使箱子的剩余空间为最小. Inp ...
- Dijkstra算法原理及证明(转)
Dijkstra算法及其证明 算法: 设G是带权图,图中的顶点多于一个,且所有的权都为正数.本算法确定从顶点S到G中其他各个顶点的距离和最短通路.在本算法中P表示带永久标记的顶点的集合.顶点A的前驱是 ...