306735: CF1245B. Restricted RPS

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Restricted RPS

题意翻译

## 题目描述 $Alice$和$Bob$要玩石头剪刀布的游戏$n$次($n$是正整数),$Alice$已经知道$Bob$每局要出什么。但是她只能出$a$次石头,$b$次剪刀和$c$次布($a,b,c$为非负整数,且保证$a+b+c=n$) $Alice$赢的条件是她**击败了**$Bob$至少 $\left\lceil\dfrac{n}{2}\right\rceil$次(向上取整),否则她输了 石头剪刀布的规则 - 石头赢剪刀 - 布赢石头 - 剪刀赢布 你的任务是,对于已给出的$Bob$的出手序列,和$a,b,c$,判断$Alice$是否能赢。如果能,找到$Alice$的出手序列 如果存在多组解,输出任意一个即可 ## 输入格式 第一行为一个整数$t(1\le t\le100)$,表示测试数据组数 对于每组数据,包含以下三行 - 第一行是一个正整数$n(1\le n\le 100)$ - 第二行包含三个非负整数,$a,b,c(0\le a,b,c\le n)$,保证$a+b+c=n$ - 第三行是一个长度为$n$的字符串$s$,$s$只由$R,P,S$三个字母组成。第$i$个字符为$R$表示$Bob$第$i$次出石头,为$P$表示他$i$次出布,为$S$表示他$i$次出剪刀。 ## 输出格式 对于每组数据 - 如果$Alice$不能赢,输出“$NO$”(不含引号) - 否则输出“$YES$”(不含引号),并且输出一个长度为$n$的字符串$t$,$t$只由$R,P,S$三个字母组成,代表赢的时候$Alice$的出手情况。$t$必须包含$a$个$R$,$b$个$P$,$c$个$S$ $YES$和$NO$的部分输出部分大小写(就是说$yEs$, $no$ 或 $YEs$都是答案),注意$R,P,S$是区分大小写的

题目描述

Let $ n $ be a positive integer. Let $ a, b, c $ be nonnegative integers such that $ a + b + c = n $ . Alice and Bob are gonna play rock-paper-scissors $ n $ times. Alice knows the sequences of hands that Bob will play. However, Alice has to play rock $ a $ times, paper $ b $ times, and scissors $ c $ times. Alice wins if she beats Bob in at least $ \lceil \frac{n}{2} \rceil $ ( $ \frac{n}{2} $ rounded up to the nearest integer) hands, otherwise Alice loses. Note that in rock-paper-scissors: - rock beats scissors; - paper beats rock; - scissors beat paper. The task is, given the sequence of hands that Bob will play, and the numbers $ a, b, c $ , determine whether or not Alice can win. And if so, find any possible sequence of hands that Alice can use to win. If there are multiple answers, print any of them.

输入输出格式

输入格式


The first line contains a single integer $ t $ ( $ 1 \le t \le 100 $ ) — the number of test cases. Then, $ t $ testcases follow, each consisting of three lines: - The first line contains a single integer $ n $ ( $ 1 \le n \le 100 $ ). - The second line contains three integers, $ a, b, c $ ( $ 0 \le a, b, c \le n $ ). It is guaranteed that $ a + b + c = n $ . - The third line contains a string $ s $ of length $ n $ . $ s $ is made up of only 'R', 'P', and 'S'. The $ i $ -th character is 'R' if for his $ i $ -th Bob plays rock, 'P' if paper, and 'S' if scissors.

输出格式


For each testcase: - If Alice cannot win, print "NO" (without the quotes). - Otherwise, print "YES" (without the quotes). Also, print a string $ t $ of length $ n $ made up of only 'R', 'P', and 'S' — a sequence of hands that Alice can use to win. $ t $ must contain exactly $ a $ 'R's, $ b $ 'P's, and $ c $ 'S's. - If there are multiple answers, print any of them. The "YES" / "NO" part of the output is case-insensitive (i.e. "yEs", "no" or "YEs" are all valid answers). Note that 'R', 'P' and 'S' are case-sensitive.

输入输出样例

输入样例 #1

2
3
1 1 1
RPS
3
3 0 0
RPS

输出样例 #1

YES
PSR
NO

说明

In the first testcase, in the first hand, Alice plays paper and Bob plays rock, so Alice beats Bob. In the second hand, Alice plays scissors and Bob plays paper, so Alice beats Bob. In the third hand, Alice plays rock and Bob plays scissors, so Alice beats Bob. Alice beat Bob 3 times, and $ 3 \ge \lceil \frac{3}{2} \rceil = 2 $ , so Alice wins. In the second testcase, the only sequence of hands that Alice can play is "RRR". Alice beats Bob only in the last hand, so Alice can't win. $ 1 < \lceil \frac{3}{2} \rceil = 2 $ .

Input

题意翻译

## 题目描述 $Alice$和$Bob$要玩石头剪刀布的游戏$n$次($n$是正整数),$Alice$已经知道$Bob$每局要出什么。但是她只能出$a$次石头,$b$次剪刀和$c$次布($a,b,c$为非负整数,且保证$a+b+c=n$) $Alice$赢的条件是她**击败了**$Bob$至少 $\left\lceil\dfrac{n}{2}\right\rceil$次(向上取整),否则她输了 石头剪刀布的规则 - 石头赢剪刀 - 布赢石头 - 剪刀赢布 你的任务是,对于已给出的$Bob$的出手序列,和$a,b,c$,判断$Alice$是否能赢。如果能,找到$Alice$的出手序列 如果存在多组解,输出任意一个即可 ## 输入格式 第一行为一个整数$t(1\le t\le100)$,表示测试数据组数 对于每组数据,包含以下三行 - 第一行是一个正整数$n(1\le n\le 100)$ - 第二行包含三个非负整数,$a,b,c(0\le a,b,c\le n)$,保证$a+b+c=n$ - 第三行是一个长度为$n$的字符串$s$,$s$只由$R,P,S$三个字母组成。第$i$个字符为$R$表示$Bob$第$i$次出石头,为$P$表示他$i$次出布,为$S$表示他$i$次出剪刀。 ## 输出格式 对于每组数据 - 如果$Alice$不能赢,输出“$NO$”(不含引号) - 否则输出“$YES$”(不含引号),并且输出一个长度为$n$的字符串$t$,$t$只由$R,P,S$三个字母组成,代表赢的时候$Alice$的出手情况。$t$必须包含$a$个$R$,$b$个$P$,$c$个$S$ $YES$和$NO$的部分输出部分大小写(就是说$yEs$, $no$ 或 $YEs$都是答案),注意$R,P,S$是区分大小写的

加入题单

上一题 下一题 算法标签: