CF955B.Not simply beatiful strings

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

我们称一个字符串是“可爱的”,如果它的字母可以重新排列,使得它们形成两个连续的、由相同字符组成的组(注意:这两个组必须包含不同的字符)。例如,ababa 是可爱的(你可以将其变换为 aaabb,其中前三个字母构成一组 a,其余字母构成一组 b),但 cccc 不是可爱的,因为在所有可能的连续划分中,这两个组中的字符都相同。

给定一个字符串 ss,请判断它是否能被划分为两个非空子序列,使得由这两个子序列分别构成的字符串都是可爱的。这里,子序列指字符串中任意一组下标(不要求连续)。

输入格式

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

唯一的一行包含字符串 ss(1 ≤ ∣s∣ ≤ 1051 \leq |s| \leq 10^5),由小写拉丁字母组成。

输出格式

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

Each letter can be printed in arbitrary case.

如果字符串能按照上述条件进行分割,则输出 «Yes»,否则输出 «No»。

每个字母可以以任意大小写形式输出。

输入输出样例

  • 输入#1

    ababa

    输出#1

    Yes
  • 输入#2

    zzcxx

    输出#2

    Yes
  • 输入#3

    yeee

    输出#3

    No

说明/提示

In sample case two zzcxx can be split into subsequences zc and zxx each of which is adorable.

There's no suitable partition in sample case three.

在第二个样例中,字符串 zzcxx 可被划分为两个子序列 zc 和 zxx,每个子序列都是可爱的。

第三个样例中不存在合适的划分。

输入解题思路,AI测评打分。不知道怎么写?

首页