https://vjudge.net/contest/356807#problem/H

题意

  A和B进行剪刀石头布n次

    A已知B出的类型顺序,同时规定A必须出三种类型的次数

    A能赢n/2局则算A赢,并给出出拳序列

    否则A输

思路

  简单模拟

  根据给定的B出拳序列构造A出拳序列

  不够的就填充剩余的类型

代码

  1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<algorithm>
5 #include<bitset>
6 #include<cassert>
7 #include<cctype>
8 #include<cmath>
9 #include<cstdlib>
10 #include<ctime>
11 #include<deque>
12 #include<iomanip>
13 #include<list>
14 #include<map>
15 #include<queue>
16 #include<set>
17 #include<stack>
18 #include<vector>
19 #include <vector>
20 #include <iterator>
21 #include <utility>
22 #include <sstream>
23 #include <limits>
24 #include <numeric>
25 #include <functional>
26 using namespace std;
27 #define gc getchar()
28 #define mem(a) memset(a,0,sizeof(a))
29 //#define sort(a,n,int) sort(a,a+n,less<int>())
30
31 #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
32
33 typedef long long ll;
34 typedef unsigned long long ull;
35 typedef long double ld;
36 typedef pair<int,int> pii;
37 typedef char ch;
38 typedef double db;
39
40 const double PI=acos(-1.0);
41 const double eps=1e-6;
42 const ll mod=1e9+7;
43 const int inf=0x3f3f3f3f;
44 const int maxn=1e5+10;
45 const int maxm=100+10;
46
47
48 bool compare(int a, int b)
49 {
50 return a < b;//升序
51 }
52
53
54 char sequence_R[100] = {0};
55 char sequence_G[100] = {0};
56 int main(){
57 int T;
58 int n = 0;
59 int s = 0 , r = 0 , p = 0;
60 int r1 = 0 , p1 = 0 , s1 = 0;
61 int sum = 0;
62 cin >> T;
63 while(T--)
64 {
65 for(int i = 0;i<n;i++)
66 {
67 sequence_R[i] = 0;
68 sequence_G[i] = 0;
69 }
70 n = 0;
71 s = 0; r = 0; p = 0;
72 r1 = 0 , p1 = 0 , s1 = 0;
73 sum = 0;
74 cin >> n;
75 cin >> r >> p >> s;
76 cin >> sequence_R;
77 for(int i = 0;i<n;i++)
78 {
79 if(sequence_R[i] == 'R') r1++;
80 if(sequence_R[i] == 'P') p1++;
81 if(sequence_R[i] == 'S') s1++;
82 }
83 sum += min(r1,p) + min(p1,s) + min(s1,r);
84
85 if(sum >= (n+1)/2)
86 {
87 cout << "YES" << endl;
88 for(int i = 0;i<n;i++)
89 {
90 if(sequence_R[i]=='R' && p > 0)
91 {
92 sequence_G[i]='P';
93 p -= 1;
94 }
95 else if(sequence_R[i]=='P' && s > 0)
96 {
97 sequence_G[i]='S';
98 s -= 1;
99 }
100 else if(sequence_R[i]=='S' && r > 0)
101 {
102 sequence_G[i]='R';
103 r -= 1;
104 }
105 }
106 for(int i = 0;i<n;i++)
107 {
108 if(sequence_G[i])
109 {
110 cout << sequence_G[i];
111 }
112 else
113 {
114 if(r)
115 {
116 cout << 'R';
117 r -= 1;
118 }
119 else if(p)
120 {
121 cout << 'P';
122 p -= 1;
123 }
124 else if(s)
125 {
126 cout << 'S';
127 s -= 1;
128 }
129 }
130 }
131 }
132 else
133 {
134 cout << "NO" << endl;
135 }
136 cout << endl;
137 }
138 return 0;
139 }

Restricted RPS CodeForces - 1245B的更多相关文章

  1. CodeForces - 1245 B - Restricted RPS(贪心)

    Codeforces Round #597 (Div. 2) Let nn be a positive integer. Let a,b,ca,b,c be nonnegative integers ...

  2. 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 ...

  3. codeforces Codeforces Round #597 (Div. 2) B. Restricted RPS 暴力模拟

    #include <bits/stdc++.h> using namespace std; typedef long long ll; ]; ]; int main() { int t; ...

  4. Codeforces Round #597 (Div. 2)

    A - Good ol' Numbers Coloring 题意:有无穷个格子,给定 \(a,b\) ,按以下规则染色: \(0\) 号格子白色:当 \(i\) 为正整数, \(i\) 号格子当 \( ...

  5. Codeforces 586D. Phillip and Trains 搜索

    D. Phillip and Trains time limit per test: 1 second memory limit per test :256 megabytes input: stan ...

  6. CodeForces 173A Rock-Paper-Scissors 数学

    Rock-Paper-Scissors 题目连接: http://codeforces.com/problemset/problem/173/A Description Nikephoros and ...

  7. Codeforces Gym 100015A Another Rock-Paper-Scissors Problem 找规律

    Another Rock-Paper-Scissors Problem 题目连接: http://codeforces.com/gym/100015/attachments Description S ...

  8. Codeforces Round #336 (Div. 2)【A.思维,暴力,B.字符串,暴搜,前缀和,C.暴力,D,区间dp,E,字符串,数学】

    A. Saitama Destroys Hotel time limit per test:1 second memory limit per test:256 megabytes input:sta ...

  9. CodeForces Round #548 Div2

    http://codeforces.com/contest/1139 A. Even Substrings You are given a string s=s1s2…sns=s1s2…sn of l ...

  10. CodeForces - 798D Mike and distribution 想法题,数学证明

    题意:给你两个数列a,b,你要输出k个下标,使得这些下标对应的a的和大于整个a数列的和的1/2.同时这些下标对应的b //题解:首先将条件换一种说法,就是要取floor(n/2)+1个数使得这些数大于 ...

随机推荐

  1. mp4文件下载,而不是在线播放

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. 洛谷 P1416 攻击火星 排版重构

    洛谷 P1416 攻击火星 原题P1416 Update 20210307 修复了挂掉的图片 20210307 重构排版 Solution understand 首先,你弄明白了什么是度吗? 一个点的 ...

  3. 通义灵码2.5+qwen3——节假日抢票不用愁,基于12306-MCP实现个人火车票智能查询小助手!

    ​ 在日常生活中,12306 是中国铁路售票系统的官方平台.为了提升购票效率.自动化查询余票信息以及获取车站代码等功能,我们希望通过使用智能体编程方式,结合 MCP(Model-as-a-Servic ...

  4. Go mod/work/get ... Golang 提供的项目管理工具该怎么用?

    自 Go 1.11 版本引入 模块(modules) 的概念以来,Go 语言的项目管理和依赖管理方式发生了根本性的变革.这一变化旨在解决早期 GOPATH 模式带来的种种不便,让项目结构更加清晰,依赖 ...

  5. cuda grid block size

    编译命令:nvcc hello.cu -o hello 运行:./hello #include <stdio.h> __global__ void helloWorldKernel() { ...

  6. helmfile调试

    说明 我们在调试helmfile编排的chart时,对于helm chart正常的情况下,我们编排的helmfile渲染模版的值出了问题,可能会存在以下的报错: helmfile template E ...

  7. 从困境到突破,EasyMR 集群迁移助力大数据底座信创国产化

    在大数据时代,企业对数据的依赖程度越来越高.然而,随着业务的不断发展和技术的快速迭代,大数据平台的集群迁移已成为企业数据中台发展途中无法回避的需求.在大数据平台发展初期,国内数据中台市场主要以国外开源 ...

  8. 大巧不工,袋鼠云正式开源大数据任务调度平台——Taier(太阿)!

    2022年2月22日,在今天这个特殊的日子里,历经多年持续迭代和千万周期实例并发调度考验的Taier(太阿)终于开源了! Github开源地址: https://github.com/DTStack/ ...

  9. 如何基于three.js(webgl)引擎架构,实现3D机房园区,数据中心消防系统

    前言前面的文章我们已经详细介绍了数据中心机房的关键知识点,以及消防领域的基础知识.在此基础上,本文将深入探讨展示消防在数据中心这一特殊场景中的应用,特别是气体消防系统的应用模拟及发生火灾时逃生路径规划 ...

  10. Web 服务器架构选择深度解析

    在 Web 服务与 API 设计中,服务器架构的选择直接决定系统的可扩展性.维护成本与性能上限.本文从架构演进脉络出发,系统解析单体架构.微服务.服务网格.Serverless 等主流架构的核心特性. ...