結果

問題 No.2148 ひとりUNO
ユーザー umezo
提出日時 2022-12-05 01:41:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 907 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 204,280 KB
最終ジャッジ日時 2025-02-09 05:18:14
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 WA * 38
権限があれば一括ダウンロードができます

ソースコード

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 t;
  cin>>t;
  while(t--){
    int n;
    cin>>n;
    
    map<int,int> m;
    vector<int> A(3);
    
    rep(i,n){
      char c;
      int d;
      cin>>c>>d;
      if(c=='R') A[0]++;
      else if(c=='G') A[1]++;
      else A[2]++;
      m[d]++;
    }
    sort(ALL(A));
    reverse(ALL(A));
    
    int c1=0,c2=0;
    for(auto [a,b]:m){
      if(b==2) c1++;
      else if(b==3) c2++;
    }
    
    if(A[1]==0) cout<<"YES"<<endl;
    else if(A[2]==0 && c1) cout<<"YES"<<endl;
    else if(A[2]==0) cout<<"NO"<<endl;
    else if(c1+c2>=2) cout<<"YES"<<endl;
    else if(c2==0) cout<<"NO"<<endl;
    else if(A[2]>=2) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
  }

  return 0;
}
0