codeforces Codeforces Round #597 (Div. 2) B. Restricted RPS 暴力模拟
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char x[];
char xx[];
int main() {
int t;
cin>>t;
while(t--) {
int a,b,c,n;
cin>>n>>a>>b>>c;
for(int i=; i<n; i++) xx[i]=;
scanf("%s",x);
int r=,p=,s=;
for(int i=; i<n; i++) {
if(x[i]=='R') r++;
else if(x[i]=='P') p++;
else s++;
}
int ans=;
ans+=min(r,b);
ans+=min(p,c);
ans+=min(s,a);
if(ans>=(n+)/) {
printf("YES\n");
for(int i=; i<n; i++) {
if(x[i]=='R'&&b>) {
xx[i]='P';
b--;
} else if(x[i]=='P'&&c>) {
xx[i]='S';
c--;
} else if(x[i]=='S'&&a>) {
a--;
xx[i]='R';
}
}
for(int i=; i<n; i++) {
if(xx[i]==) {
if(a>) {
printf("R");
a--;
} else if(b>) {
printf("P");
b--;
} else if(c>) {
c--;
printf("S");
}
} else printf("%c",xx[i]);
}
printf("\n");
} else {
printf("NO\n");
}
}
return ;
}
codeforces Codeforces Round #597 (Div. 2) B. Restricted RPS 暴力模拟的更多相关文章
- Codeforces Round #597 (Div. 2) B. Restricted RPS
链接: https://codeforces.com/contest/1245/problem/B 题意: Let n be a positive integer. Let a,b,c be nonn ...
- Codeforces Round #164 (Div. 2) A. Games【暴力/模拟/每个球队分主场和客场,所有球队两两之间进行一场比赛,要求双方球服颜色不能相同】
A. Games time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
随机推荐
- Python_基础数据类型
一,首先介绍一下变量 1. 变量是什么 在Python中,变量的概念基本上和初中代数的方程变量是一致的. 2. 变量命名规则 由数字.字母.下划线组成 不能以数字开头 要具有描述性 要区分大小写 禁止 ...
- python scraping webs - python取得NIPS oral paper列表
from lxml import html import requests # using xpath # page = requests.get('http://econpy.pythonanywh ...
- Python GUI编程(TKinter)(简易计算器)
搞课设搞得心累,现在看到人脸这两个字就烦躁,无聊搞搞tkinter,实现一个计算器的功能,能够简单的加减乘除. 简单的页面如下: 简单的代码如下: # encoding:utf-8 import tk ...
- easyUI footer 的格式渲染
网上好多的例子,但是自己使用的情况下还是出现bug.比如以下代码: var myview = $.extend({}, $.fn.datagrid.defaults.view, { renderFoo ...
- JS首字母进行分类合并加排序
let array = ['fds', 'ewfg1', 'cvd', 'ew', 'qer', 'jjh', 'rth', 'asd', 'vsd', 'tteh', 'fxv']; let map ...
- ubuntu 16.04.1上安装并使用nginx
1.安装 sudo apt-get install nginx 2.这时候应该就已经启动了,跳到步骤4. 通过命令“ps -aux | grep nginx”看下是否启动 3.如果没有启动,可以使用命 ...
- source insight增加tab标签页的方法之sihook
1.效果如下 2.方法见如下博客 http://www.cnblogs.com/Red_angelX/archive/2013/01/23/2873603.html
- 虚拟机floppy0
网上搜索方法是:删除该虚拟机的软盘即可. 具体原因还不知道,以后再补上原因
- Graph Regularized Feature Selection with Data Reconstruction
Abstract • 从图正则数据重构方面处理无监督特征选择: • 模型的思想是所选特征不仅通过图正则保留了原始数据的局部结构,也通过线性组合重构了每个数据点: • 所以重构误差成为判断所选特征质量的 ...
- K3标准产品的BOS单据发布至自定义模块
在自定义模块 下先随便发布一张单据,然后后台更新数据表. select * from icclasstype where fname_chs like '付款申请单%' --查询表单的ID upd ...