提交时间:2022-04-10 15:20:10

运行 ID: 48183

#include <bits/stdc++.h> using namespace std; const int N = 105, T = 52; int a[N + 3 * T], b[N + 3 * T], c[N + 3 * T], d[N + 3 * T], n, t; inline void print(int x, int y) { if (x == 1) printf("G"); else { printf("R"); if (y > 1) printf("(%d)", y); } } void solve() { cin >> n >> t; char x; for (int i = 1; i <= n; i++) { cin >> x; a[i] = (x == 'R' ? 3 : 1); b[i] = 1; } for (int i = 1; i <= t; i++) { for (int j = 1; j <= n + 3 * t; j++) { if (a[j] == 1) { c[j + a[j]] = 1; d[j + a[j]] = 1; } } for (int j = 1; j <= n + 3 * t; j++) { if (a[j] == 3) { int k = j + a[j]; while (c[k] == 1) k--; c[k] = 3; d[k] += b[j]; } } for (int j = 1; j <= n + 3 * t; j++) { if (c[j] && d[j]) { print(c[j], d[j]); } a[j] = c[j]; c[j] = 0; b[j] = d[j]; d[j] = 0; } printf("\n"); } } int main() { //freopen("race.in", "r", stdin); //freopen("race.out", "w", stdout) solve(); return 0; }