結果

問題 No.2148 ひとりUNO
ユーザー umezoumezo
提出日時 2022-12-05 02:12:02
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 1,338 bytes
コンパイル時間 2,352 ms
コンパイル使用メモリ 213,540 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 06:39:37
合計ジャッジ時間 3,790 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,376 KB
testcase_01 AC 4 ms
5,376 KB
testcase_02 AC 5 ms
5,376 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 7 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 5 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 20 ms
5,376 KB
testcase_17 AC 20 ms
5,376 KB
testcase_18 AC 19 ms
5,376 KB
testcase_19 AC 17 ms
5,376 KB
testcase_20 AC 18 ms
5,376 KB
testcase_21 AC 17 ms
5,376 KB
testcase_22 AC 17 ms
5,376 KB
testcase_23 AC 17 ms
5,376 KB
testcase_24 AC 17 ms
5,376 KB
testcase_25 AC 18 ms
5,376 KB
testcase_26 AC 9 ms
5,376 KB
testcase_27 AC 9 ms
5,376 KB
testcase_28 AC 8 ms
5,376 KB
testcase_29 AC 8 ms
5,376 KB
testcase_30 AC 8 ms
5,376 KB
testcase_31 AC 8 ms
5,376 KB
testcase_32 AC 9 ms
5,376 KB
testcase_33 AC 8 ms
5,376 KB
testcase_34 AC 8 ms
5,376 KB
testcase_35 AC 8 ms
5,376 KB
testcase_36 AC 8 ms
5,376 KB
testcase_37 AC 9 ms
5,376 KB
testcase_38 AC 9 ms
5,376 KB
testcase_39 AC 2 ms
5,376 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 t;
  cin>>t;
  while(t--){
    int n;
    cin>>n;
    
    map<int,int> m,m1,m2,m3;
    vector<int> A(3);
    vector<vector<int>> G(3);
    
    rep(i,n){
      char c;
      int d;
      cin>>c>>d;
      if(c=='R') A[0]++,G[0].push_back(d);
      else if(c=='G') A[1]++,G[1].push_back(d);
      else A[2]++,G[2].push_back(d);
      m[d]++;
    }
    sort(ALL(A));
    reverse(ALL(A));
    
    int c1=0,c2=0;
    set<int> s;
    for(auto [a,b]:m){
      if(b==2) c1++;
      else if(b==3) c2++;
      if(b>=2) s.insert(a);
    }
    
    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(c2>=2 || (c1>=1 && c2==1)) cout<<"YES"<<endl;
    else if(c2==0 && c1<=1) cout<<"NO"<<endl;
    else if(c2==1 && A[2]>=2) cout<<"NO"<<endl;
    else if(c2==1) cout<<"YES"<<endl;
    else{
      bool b=true;
      rep(j,3){
        bool f=false;
        rep(l,G[j].size()){
          if(s.count(G[j][l])) f=true;
        }
        if(f==false) b=false;
      }
      if(b) cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
    } 
  }

  return 0;
}
0