Educational Codeforces Round 91 (Rated for Div. 2) B. Universal Solution
Posted kanoon
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Educational Codeforces Round 91 (Rated for Div. 2) B. Universal Solution相关的知识,希望对你有一定的参考价值。
题目链接:https://codeforces.com/contest/1380/problem/B
题意
你在和一个机器人玩石头剪刀布,给出一个长为 $n$ 的出拳序列,机器人会从某一处开始出拳 $n$ 次,问你要怎么出拳才能赢尽可能多的回合。
题解
全部反制机器人会出的最多的拳即可。
代码
#include <bits/stdc++.h> using namespace std; map<char, char> mp{ {‘R‘, ‘P‘}, {‘S‘, ‘R‘}, {‘P‘, ‘S‘} }; void solve() { string s; cin >> s; int mx = 0; map<char, int> cnt; for (char c : s) mx = max(mx, ++cnt[c]); for (char c : {‘R‘, ‘S‘, ‘P‘}) { if (cnt[c] == mx) { cout << string(s.size(), mp[c]) << " "; return; } } } int main() { int t; cin >> t; while (t--) solve(); }
以上是关于Educational Codeforces Round 91 (Rated for Div. 2) B. Universal Solution的主要内容,如果未能解决你的问题,请参考以下文章
Educational Codeforces Round 7 A
Educational Codeforces Round 7
Educational Codeforces Round 90
Educational Codeforces Round 33