結果

問題 No.2042 RGB Caps
コンテスト
ユーザー vjudge1
提出日時 2025-11-05 16:00:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,077 bytes
コンパイル時間 2,053 ms
コンパイル使用メモリ 199,428 KB
実行使用メモリ 7,724 KB
最終ジャッジ日時 2025-11-05 16:00:43
合計ジャッジ時間 6,376 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int t;
  t = 1;

  while (t--)
  {
    int n, k;
    cin >> n >> k;
    string s;
    for (int i = 0; i < n; i++)
    {
      if (i % 3 == 0)
      {
        s = s + 'R';
      }
      if (i % 3 == 1)
      {
        s = s + 'G';
      }
      if (i % 3 == 2)
      {
        s = s + 'B';
      }

    }
    if (n % 3 == 1)
    {
      s = s + 'G';
      s = s + 'B';

    }
    if (n % 3 == 2)
    {

      s += 'B';

    }
    if (n % 3 == 0)
    {
      s = s + 'R';
      s = s + 'G';
      s = s + 'B';

    }
    for (int i = 0; i < k; i++)
    {
      int a;
      char c;

      cin >> a >> c;
      if (a % 3 == 1)
      {
        if (c == 'G')
        {
          swap(s[a - 1], s[a]);
        }
        if (c == 'B')
        {
          swap(s[a - 1], s[a + 1]);
        }

      }
      if (a % 3 == 2)
      {
        if (c == 'B')
        {
          swap(s[a - 1], s[a ]);
        }
      }

    }
    for (int i = 0; i < n; i++)
    {
      cout << s[i];
    }
    cout << endl;



  }


  return 0;
}
0