提交时间:2022-04-13 08:43:05

运行 ID: 48446

#include <bits/stdc++.h> using namespace std; const int N = 105, T = 52; int a[N + 3 * T]; int b[N + 3 * T]; int c[N + 3 * T]; int d[N + 3 * T]; int n, t; void print(int x, int y) { if (x == 1) printf("G"); else { printf("R"); if (y > 1) printf("(%d)", y); } } int main() { //freopen("race.in", "r", stdin); //freopen("race.out", "w", stdout); 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"); } return 0; }