CF626B.Cards

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions:

  • take any two (not necessarily adjacent) cards with different colors and exchange them for a new card of the third color;
  • take any two (not necessarily adjacent) cards with the same color and exchange them for a new card with that color.

She repeats this process until there is only one card left. What are the possible colors for the final card?

凯瑟琳有一副包含 nn 张卡片的牌组,每张卡片的颜色为红色、绿色或蓝色中的一种。只要剩余卡片数不少于两张,她就可以执行以下两种操作之一:

  • 任取两张(不一定相邻)颜色不同的卡片,并用一张第三种颜色的卡片替换它们;
  • 任取两张(不一定相邻)颜色相同的卡片,并用一张同色的卡片替换它们。

她不断重复此过程,直到只剩一张卡片为止。问:最后一张卡片可能是什么颜色?

输入格式

The first line of the input contains a single integer n (1 ≤ n ≤ 200) — the total number of cards.

The next line contains a string s of length n — the colors of the cards. s contains only the characters 'B', 'G', and 'R', representing blue, green, and red, respectively.

输入的第一行包含一个整数 nn(1≤n≤2001 \leq n \leq 200)—— 卡片的总数。

接下来的一行包含一个长度为 nn 的字符串 ss —— 表示卡片的颜色。ss 中仅包含字符 'B'、'G' 和 'R',分别代表蓝色、绿色和红色。

输出格式

Print a single string of up to three characters — the possible colors of the final card (using the same symbols as the input) in alphabetical order.

输出一个最多包含三个字符的字符串——最终卡片可能的颜色(使用与输入相同的符号),按字母顺序排列。

输入输出样例

  • 输入#1

    2
    RB

    输出#1

    G
  • 输入#2

    3
    GRG

    输出#2

    BR
  • 输入#3

    5
    BBBBB

    输出#3

    B

说明/提示

In the first sample, Catherine has one red card and one blue card, which she must exchange for a green card.

In the second sample, Catherine has two green cards and one red card. She has two options: she can exchange the two green cards for a green card, then exchange the new green card and the red card for a blue card. Alternatively, she can exchange a green and a red card for a blue card, then exchange the blue card and remaining green card for a red card.

In the third sample, Catherine only has blue cards, so she can only exchange them for more blue cards.

在第一个样例中,凯瑟琳有一张红色卡片和一张蓝色卡片,她必须将它们交换成一张绿色卡片。

在第二个样例中,凯瑟琳有两张绿色卡片和一张红色卡片。她有两种选择:她可以先用两张绿色卡片交换一张绿色卡片,再用这张新得到的绿色卡片和那张红色卡片交换一张蓝色卡片;或者,她可以先用一张绿色卡片和一张红色卡片交换一张蓝色卡片,再用这张蓝色卡片和剩下的绿色卡片交换一张红色卡片。

在第三个样例中,凯瑟琳只有蓝色卡片,因此她只能用蓝色卡片交换更多的蓝色卡片。

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

首页