Codeforces--626B--Cards(模拟)
Time Limit: 2000MS |
Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u |
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
2
RB
G
3
GRG
BR
5
BBBBB
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(模拟)的更多相关文章
- Codeforces 626B Cards(模拟+规律)
B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...
- CodeForces 626B Cards
瞎搞题...凭直觉+猜测写了一发,居然AC了.. #include<cstdio> #include<cstring> #include<cmath> #inclu ...
- Codeforces Round #304 (Div. 2) C. Soldier and Cards —— 模拟题,队列
题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果 ...
- Codeforces 389B(十字模拟)
Fox and Cross Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submi ...
- CF Soldier and Cards (模拟)
Soldier and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- codeforces 591B Rebranding (模拟)
Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...
- Codeforces 631C. Report 模拟
C. Report time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...
- Codeforces 679B. Barnicle 模拟
B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input ...
- CodeForces 382C【模拟】
活生生打成了大模拟... #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsig ...
- codeforces 719C (复杂模拟-四舍五入-贪心)
题目链接:http://codeforces.com/problemset/problem/719/C 题目大意: 留坑...
随机推荐
- 【PostgreSQL-9.6.3】分区表
PostgreSQL中的分区表是通过表继承来实现的(表继承博客http://www.cnblogs.com/NextAction/p/7366607.html).创建分区表的步骤如下: (1)创建“父 ...
- [Windows Server 2003] 安装IIS6.0及FTP
★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频.★ 本节我们将带领大家:安装IIS6. ...
- 拍拍贷投资工具|拍拍贷投标工具|PPD投标工具|PPD投资工具介绍
我们先来分析一下现在市场上在PPD投资的途径: 其他解决方案 1.在网站或者手机客户端手动投标 这种方法对于非常小额的资金是可以的,稍微多一点就会发现不可行,目前PPD手动刷新出来的标几乎都是你刚刷新 ...
- 在Windows下安装Elasticsearch5.0
1.准备工作 安装和配置Java环境 2.下载 地址:https://www.elastic.co/downloads/elasticsearch 老版本:https://www.elastic.co ...
- mysql_基础1
初学mysql,感觉挺有意思的. mysql指令的一些参数: promrt修改提示符: PROMPT \D mysql的语法规范: 一些函数: 创建数据库: SHOW CREATE DATABAS ...
- C# 金钱添加逗号0000
private void Form1_Load(object sender, EventArgs e) { decimal dd = (decimal)11234567890.01; string d ...
- pycharm之gitignore设置
首先检查pycharm是否安装了ignore插件 项目目录如图: 选中项目automationTest名称,右击-->New-->查看是否有ignore file选项,如果有表示Pycah ...
- node.js(API解读) - process (http://snoopyxdy.blog.163.com/blog/static/60117440201192841649337/)
node.js(API解读) - process 2011-10-28 17:05:34| 分类: node | 标签:nodejs nodejsprocess node.jsprocess ...
- CentOS / RHEL 7 : Chrony V/s NTP (Differences Between ntpd and chronyd)
CentOS / RHEL 7 : Chrony V/s NTP (Differences Between ntpd and chronyd) Chosing between Chrony and N ...
- 计蒜客 成绩统计 (Hash表)
链接 : Here! 思路 : 如果用 $STL$ 的 $map$ 或者是使用 $unordered\underline{}map$ 的话是会 $T$ 的, 所以得手写一个 $hash表$. 其实这个 ...