結果
問題 |
No.2148 ひとりUNO
|
ユーザー |
![]() |
提出日時 | 2022-12-05 00:36:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,976 bytes |
コンパイル時間 | 2,477 ms |
コンパイル使用メモリ | 212,508 KB |
最終ジャッジ日時 | 2025-02-09 05:15:48 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 WA * 30 |
ソースコード
#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; vector<pair<int,set<int>>> S(3); rep(i,n){ char c; int d; cin>>c>>d; if(c=='R'){ S[0].second.insert(d); S[0].first++; } if(c=='G'){ S[1].second.insert(d); S[1].first++; } if(c=='B'){ S[2].second.insert(d); S[2].first++; } } sort(ALL(S)); reverse(ALL(S)); if(S[1].first==0) cout<<"YES"<<'\n'; else if(S[2].first==0){ bool b=false; for(auto x:S[1].second){ if(S[0].second.count(x)){ b=true; break; } } if(b) cout<<"YES"<<'\n'; else cout<<"NO"<<'\n'; } else{ bool b=false,c=false; for(auto x:S[2].second){ if(S[1].second.count(x)){ b=true; break; } } for(auto x:S[1].second){ if(S[0].second.count(x)){ c=true; break; } } if(b && c){ cout<<"YES"<<'\n'; continue; } b=false,c=false; for(auto x:S[2].second){ if(S[0].second.count(x)){ b=true; break; } } for(auto x:S[1].second){ if(S[0].second.count(x)){ c=true; break; } } if(b && c){ cout<<"YES"<<'\n'; continue; } b=false,c=false; for(auto x:S[2].second){ if(S[1].second.count(x)){ b=true; break; } } for(auto x:S[2].second){ if(S[0].second.count(x)){ c=true; break; } } if(b && c) cout<<"YES"<<'\n'; else cout<<"NO"<<'\n'; } } return 0; }