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> ...
随机推荐
- tensorflow张量排序
本篇记录一下TensorFlow中张量的排序方法 tf.sort和tf.argsort # 声明tensor a是由1到5打乱顺序组成的 a = tf.random.shuffle(tf.range( ...
- .net mvc接收对象数组 通过ajax提交
ajax代码 var obj = {}; obj.RoomName = ""; obj.RoomCode = ""; $.ajax({ type: " ...
- 真·从零开始的Ubuntu+Apache+MySQL+PHP+phpstorm+xdebug下的debug环境搭建(纯小白向)
费了好几天劲,终于把Linux下的开发环境如何设置搞的有点明白了,在此写篇博客庆祝一下,让大家以后少踩坑(缓慢更新中) 关键词 win10双系统装Ubuntu 下载U盘烧录工具 下载UbuntuLTS ...
- 积分题1之来自G.Han的一道积分题
今天,收到G.Han的提问,第一个是计算积分 \[\int_0^{\infty}{\frac{\ln x}{(x^2+1)^n}dx}\]顿时不明觉厉,然后在宝典<Table of Integr ...
- matlab HW求法笔记
for i=1:9400 Sbox_out_11(i) = length(findstr(num2str(dec2bin(Sbox_out_1(i,:))),'1')); end
- 15. 3Sum、16. 3Sum Closest和18. 4Sum
15 3sum Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = ...
- Eclispe WEB项目 转到 IDEA 后无法部署问题
IDEA是个强大的IDE 这个就不用多说了 Eclispe 的Web项目 转到IDEA之后,开始部署会出现大量的问题 项目从SVN下载下来的时候,大概就是这个样 第一步是先设置 项目结构 也就 ...
- IntelliJ IDEA实用插件推荐
IntelliJ在业界被公认为优秀的Java开发平台之一,在智能代码助手.代码自动提示.重构.J2EE支持.代码审查. 创新的GUI设计等方面表现突出,并支持基于Android平台的程序开发.通过插件 ...
- 使用ajax向后台发送数据
第一种最原始的方式就是手动拼接json数组: var name="text"; $.ajax({ url:"". data:{'name':name} succ ...
- RN开发-IDE和API
一.开发工具 1.Visual Studio Code:微软IDE,轻量级,只有30+M大小 2.nuclide :仅支持Mac 3.WebStorm : JavaScript开发工具(IDE) 二. ...