CF957A.Tritonic Iridescence

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.

Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into n consecutive segments, each segment needs to be painted in one of the colours.

Arkady has already painted some (possibly none or all) segments and passes the paintbrush to you. You are to determine whether there are at least two ways of colouring all the unpainted segments so that no two adjacent segments are of the same colour. Two ways are considered different if and only if a segment is painted in different colours in them.

眺望着万千春色交织而成的迷人画卷,画家阿尔卡季铺开了一幅极长的画布。

阿尔卡季拥有足量的三种颜色颜料:青色(cyan)、品红色(magenta)和黄色(yellow)。画布是一维的,被划分为 nn 个连续的段,每一段必须涂上这三种颜色中的一种。

阿尔卡季已预先涂好了其中若干段(可能一段未涂,也可能全部涂完),随后将画笔交予你。你需要判断:是否存在至少两种方式,为所有尚未涂色的段着色,使得任意两个相邻段的颜色均不相同。当且仅当存在某一段在两种方案中被涂成不同颜色时,这两种方案才被视为不同。

输入格式

The first line contains a single positive integer n (1 ≤ n ≤ 100) — the length of the canvas.

The second line contains a string s of n characters, the i-th of which is either 'C' (denoting a segment painted in cyan), 'M' (denoting one painted in magenta), 'Y' (one painted in yellow), or '?' (an unpainted one).

第一行包含一个正整数 nn(1≤n≤1001 \leq n \leq 100)——画布的长度。

第二行包含一个长度为 nn 的字符串 ss,其中第 ii 个字符为以下之一:'C'(表示青色涂绘的段)、'M'(表示品红色涂绘的段)、'Y'(表示黄色涂绘的段)或 '?'(表示未涂绘的段)。

输出格式

If there are at least two different ways of painting, output "Yes"; otherwise output "No" (both without quotes).

You can print each character in any case (upper or lower).

如果存在至少两种不同的涂色方式,则输出“Yes”;否则输出“No”(均不带引号)。

您可以以任意大小写(大写或小写)输出每个字符。

输入输出样例

  • 输入#1

    5
    CY??Y

    输出#1

    Yes
  • 输入#2

    5
    C?C?Y

    输出#2

    Yes
  • 输入#3

    5
    ?CYC?

    输出#3

    Yes
  • 输入#4

    5
    C??MM

    输出#4

    No
  • 输入#5

    3
    MMY

    输出#5

    No

说明/提示

For the first example, there are exactly two different ways of colouring: CYCMY and CYMCY.

For the second example, there are also exactly two different ways of colouring: CMCMY and CYCMY.

For the third example, there are four ways of colouring: MCYCM, MCYCY, YCYCM, and YCYCY.

For the fourth example, no matter how the unpainted segments are coloured, the existing magenta segments will prevent the painting from satisfying the requirements. The similar is true for the fifth example.

对于第一个例子,恰好有两种不同的染色方式:CYCMY 和 CYMCY。

对于第二个例子,也恰好有两种不同的染色方式:CMCMY 和 CYCMY。

对于第三个例子,共有四种染色方式:MCYCM、MCYCY、YCYCM 和 YCYCY。

对于第四个例子,无论未涂色的线段如何染色,已有的品红色(magenta)线段都会导致染色无法满足要求。第五个例子的情况类似。

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

首页