結果

問題 No.2042 RGB Caps
ユーザー umezo
提出日時 2022-08-19 22:41:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 766 bytes
コンパイル時間 2,338 ms
コンパイル使用メモリ 204,892 KB
最終ジャッジ日時 2025-01-31 01:29:04
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

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