結果
| 問題 |
No.2148 ひとりUNO
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-11 01:51:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| コード長 | 2,342 bytes |
| コンパイル時間 | 2,072 ms |
| コンパイル使用メモリ | 204,108 KB |
| 最終ジャッジ日時 | 2025-02-09 09:30:46 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 39 |
ソースコード
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;
void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);}
void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}
void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);}
void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);}
void ioinit() { cout<<fixed<<setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); }
#define debug1(a) { cerr<<#a<<":"<<a<<endl; }
#define debug2(a,b) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl; }
#define debug3(a,b,c) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl; }
#define debug4(a,b,c,d) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl; }
// clang-format on
bool solve() {
ll N;
cin >> N;
vector<vector<ll>> colors(3, vector<ll>(N + 1));
unordered_set<ll> colorset;
for (ll i = 0; i < N; i++) {
char c;
ll d;
cin >> c >> d;
ll cc = 0;
if (c == 'R') cc = 0;
if (c == 'G') cc = 1;
if (c == 'B') cc = 2;
colorset.insert(cc);
colors[cc][d]++;
}
vector<ll> kinds(8);
for (ll i = 1; i <= N; i++) {
ll kind = 0;
for (ll c = 0; c < 3; c++) {
if (colors[c][i]) {
kind += 1 << c;
}
}
kinds[kind]++;
}
ll one = (kinds[1] > 0) + (kinds[2] > 0) + (kinds[4] > 0);
ll two = (kinds[3] > 0) + (kinds[5] > 0) + (kinds[6] > 0);
ll three = (kinds[7] > 0);
ll all_color = colorset.size();
if (all_color == 1) {
return true;
}
if (all_color == 2) {
if (two) return true;
return false;
}
if (three) {
if (two) return true;
if (kinds[7] >= 2) return true;
if (one <= 2) return true;
return false;
}
if (two >= 2) return true;
return false;
}
int main() {
ioinit();
ll T;
cin >> T;
while (T--) {
print(solve() ? "YES" : "NO");
}
return 0;
}