https://ac.nowcoder.com/acm/contest/332/F
C++版本一
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define For(i, sum, y) for (int i = sum; i <= y; i++)
#define _For(i, sum, y) for (int i = sum; i >= y; i--)
#define Mem(f, sum) memset(f, sum, sizeof(f))
#define Sca(sum) scanf("%d", &sum)
#define Sca2(sum, y) scanf("%d%d", &sum, &y)
#define Sca3(sum, y, z) scanf("%d%d%d", &sum, &y, &z)
#define Scl(sum) scanf("%lld", &sum);
#define Pri(sum) printf("%d\n", sum)
#define Prl(sum) printf("%lld\n", sum);
#define CLR(u) \
for (int i = 0; i <= N; i++) \
u[i].clear();
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define PII pair<int, int>
#define PIL pair<int, long long>
#define PLL pair<long long, long long>
#define pb push_back
#define fi first
#define se second
typedef vector<int> VI;
const double eps = 1e-9;
const int maxn = 2e6 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int ans[maxn],R,S,P;
void dfs(int sum, int l, int r) {
bool flag = false;
int m = (l + r) >> 1;
if (l == r){
ans[l] = sum;
if (sum == 0) P++;
if (sum == 1) R++;
if (sum == 2) S++;
return;
}
if (sum == 0){
dfs(0, l, m);
dfs(1, m + 1, r);
}
if (sum == 1){
dfs(1, l, m);
dfs(2, m + 1, r);
}
if (sum == 2){
dfs(0, l, m);
dfs(2, m + 1, r);
}
for (int i = l; i <= m; i++){
if (ans[i] < ans[m + i - l + 1]) break;
if (ans[i] > ans[m + i - l + 1]){
flag = true;
break;
}
}
if (flag) for(int i = l; i <= m; i++) swap(ans[i], ans[m + i - l + 1]);
}
int main(){
int r,p,s;
scanf("%d %d %d", &r, &p, &s);
int sum = r + s + p;
for (int i = 0; i <= 2; i++) {
R = S = P = 0;
dfs(i, 1, sum);
if (R == r && S == s && P == p){
for (int i = 1; i <= sum; i++){
if (ans[i] == 0) printf("P");
if (ans[i] == 1) printf("R");
if (ans[i] == 2) printf("S");
}
puts("");
exit(0);
}
}
puts("IMPOSSIBLE"); //没有输出的话
return 0;
}