Cards

Time Limit: 2000MS

  Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit
Status

Description

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?

Input

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.

Output

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.

Sample Input

Input
2
RB
Output
G
Input
3
GRG
Output
BR
Input
5
BBBBB
Output
B

Sample Output

Hint

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.

Source


如果只有一种颜色,那么只可能生成一种颜色,如果有两种就要分情况了,如果两种颜色各一个,输出的也只能有一种颜色,,,,,,,,

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char str[10010];
int main()
{
int n;
cin>>n;
cin>>str;
int R,G,B;
R=B=G=0;
for(int i=0;i<n;i++)
{
if(str[i]=='R') R++;
if(str[i]=='G') G++;
if(str[i]=='B') B++;
}
if(R&&G==0&&B==0) cout<<"R"<<endl;
else if(R==0&&G&&B==0) cout<<"G"<<endl;
else if(R==0&&G==0&&B) cout<<"B"<<endl;
else if(R==1&&G==1&&B==0) cout<<"B"<<endl;
else if(R==1&&G==0&&B==1) cout<<"G"<<endl;
else if(R==0&&G==1&&B==1) cout<<"R"<<endl; else if(R==1&&G==0&&B>1) cout<<"GR"<<endl;
else if(R==1&&G>1&&B==0) cout<<"BR"<<endl;
else if(R==0&&G==1&&B>1) cout<<"GR"<<endl;
else if(R==0&&G>1&&B==1) cout<<"BR"<<endl;
else if(R>1&&G==1&&B==0) cout<<"BG"<<endl;
else if(R>1&&G==0&&B==1) cout<<"BG"<<endl; else cout<<"BGR"<<endl;
return 0;
}

Codeforces--626B--Cards(模拟)的更多相关文章

  1. Codeforces 626B Cards(模拟+规律)

    B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...

  2. CodeForces 626B Cards

    瞎搞题...凭直觉+猜测写了一发,居然AC了.. #include<cstdio> #include<cstring> #include<cmath> #inclu ...

  3. Codeforces Round #304 (Div. 2) C. Soldier and Cards —— 模拟题,队列

    题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果 ...

  4. Codeforces 389B(十字模拟)

    Fox and Cross Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submi ...

  5. CF Soldier and Cards (模拟)

    Soldier and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  6. codeforces 591B Rebranding (模拟)

    Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...

  7. Codeforces 631C. Report 模拟

    C. Report time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...

  8. Codeforces 679B. Barnicle 模拟

    B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input ...

  9. CodeForces 382C【模拟】

    活生生打成了大模拟... #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsig ...

  10. codeforces 719C (复杂模拟-四舍五入-贪心)

    题目链接:http://codeforces.com/problemset/problem/719/C 题目大意: 留坑...

随机推荐

  1. JS——delete

    1.对象属性删除 <script> function fun(){ this.name = 'mm'; } var obj = new fun(); console.log(obj.nam ...

  2. JS——拖拽盒子

    注意事项: 1.opacity是全部元素变透明,rgba只是背景色变透明 2.先是注册鼠标按下的事件,此时就需要记录鼠标在盒子中的坐标 3.再在鼠标按下事件中注册鼠标移动事件,此时鼠标的坐标是不断变化 ...

  3. 关于python中的staticmethod

    python中的staticmethod 主要是方便将外部函数集成到类体中,美化代码结构,重点在不需要类实例化的情况下调用方法 如果你去掉staticmethod,在方法中加self也可以通过实例化访 ...

  4. 【LeetCode】1、Two Sum

    题目等级:Easy 题目描述:   Given an array of integers, return indices of the two numbers such that they add u ...

  5. c/c++排坑(5) -- c语言中的申明

    C语言的申明总是令人头大,对于这块内容也一直让我头疼.希望通过这篇博客能够稍微梳理一下.材料和例子来源于<C专家编程> 一.C语言的申明的优先级规则 先来个例子,看看下面这行C代码到底是个 ...

  6. 7-20 Windows消息队列 (25 分)(模拟水题)

    题意: 思路: 用优先队列直接模拟就OK了,另外优先队列存pair的时候比较的是first的值,实测!! 上代码: #include <iostream> #include <que ...

  7. Windows环境下flask+Apache+mod_wsgi部署及爬坑

    文章目录 安装python Windows 环境使用virtualenv和virtualenvwrapper 安装mod_wsgi 安装nginx 安装Apache 遇到的坑 安装Apache遇到的坑 ...

  8. 关于read和fread

    1.fread与read的区别---open和fopen的区别--fread函数和fwrite函数:http://blog.csdn.net/dreamtdp/article/details/7560 ...

  9. 公钥基本结构(PKI)的概念

    公钥证书 ,通常简称为证书 ,用于在 Internet.Extranet 和 Intranet 上进行身份验证并确保数据交换的安全.证书的颁发者和签署者就是众所周知的 证书颁发机构 (CA),将在下一 ...

  10. 【郑轻邀请赛 H】 维克兹的进制转换

    [题目链接]:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2134 [题意] [题解] 设f[i]表示数字i分解为二进制数的方案数; 则 如果i为 ...