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 题目大意: 留坑...
随机推荐
- JavaScript定时器及其他
By Abyssly Jun 20 2014 Updated:Jun 20 2014 平时工作中不可避免地要嵌套网页,对JavaScript的深入了解还是很有必要滴.而JavaScript中一个容易让 ...
- 【转载】HTTP 响应头与状态码
原文地址:https://segmentfault.com/a/1190000006689786 HTTP Response Header 响应头域允许服务器传递不能放在状态行的附加信息,这些域主要描 ...
- [ECharts]"echarts/config" is not exists
今天在给Echarts折线图中的数据点增加点击事件的时候总是出现一个 Uncaught Error: [MODULE_MISS]"echarts/config" is not ex ...
- (转)OGNL与值栈
http://blog.csdn.net/yerenyuan_pku/article/details/67709693 OGNL的概述 什么是OGNL 据度娘所说: OGNL是Object-Graph ...
- PC、h5项目接入第三方支付宝扫码登录、扫码付款
首先介绍一下pc项目接入支付宝扫码支付. 1.pc.移动接入支付宝扫码支付. 其实这个逻辑很简单,前端所需要处理的不是很多,后台会给一个连接,前端只需要将要支付的订单id拼接在这个连接上,然后打开跳转 ...
- groupbox
使用groupbox将radiobox 放入其中可以使组框中只选中一个
- Sping——使用注解创建切面
为讲解例子,我们首先定义一个Performance接口: package aoptest; public interface Performance { public void perform(); ...
- uva1584 Circular Sequence(Uva-1584)
vj:https://vjudge.net/problem/UVA-1584 这个题讲的是一个圆环,圆环上面有一堆字母,找出字典序最小的那一圈 这个题我觉得直接用c语言的strcmp那一套感觉真是用不 ...
- Asp.NET误人子弟教程:在MVC里面结合JQ实现AJAX
public class Person { public string Name { get; set; } public string City { get; set; } public strin ...
- odoo 二次开发小记-----不定时更新
一.odoo中 页面上字段变化引起其他字段范围变化-onchange @api.onchange('company_id') def onchange_parent_id(self): return ...