結果

問題 No.2042 RGB Caps
ユーザー umezoumezo
提出日時 2022-08-19 22:41:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 766 bytes
コンパイル時間 1,982 ms
コンパイル使用メモリ 213,036 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 20:35:17
合計ジャッジ時間 2,975 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 9 ms
6,940 KB
testcase_07 AC 8 ms
6,944 KB
testcase_08 AC 12 ms
6,944 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 18 ms
6,944 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 20 ms
6,944 KB
testcase_13 AC 19 ms
6,944 KB
testcase_14 AC 19 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 7 ms
6,944 KB
testcase_17 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n,k;
  cin>>n>>k;
  vector<char> A(n+3,'?');
  rep(i,k){
    int a;
    char c;
    cin>>a>>c;
    a--;
    A[a]=c;
  }
  vector<char> ANS;
  rep(i,n/3+1){
    map<char,int> M;
    vector<char> B;
    for(int j=0;j<3;j++){
      int t=i*3+j;
      if(A[t]!='?' && M[A[t]]==0){
        B.push_back(A[t]);
        M[A[t]]++;
      }
    }
    if(M['R']==0) B.push_back('R');
    if(M['G']==0) B.push_back('G');   
    if(M['B']==0) B.push_back('B');
    rep(j,3) ANS.push_back(B[j]);
  }
  rep(i,n) cout<<ANS[i];
  cout<<endl;
 
  return 0;
}
0