結果
| 問題 |
No.2148 ひとりUNO
|
| コンテスト | |
| ユーザー |
t33f
|
| 提出日時 | 2022-12-08 23:14:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,642 bytes |
| コンパイル時間 | 939 ms |
| コンパイル使用メモリ | 84,904 KB |
| 最終ジャッジ日時 | 2025-02-09 06:32:40 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 WA * 26 |
ソースコード
#include <numeric>
#include <set>
#include <array>
#include <vector>
#include <iostream>
using namespace std;
constexpr int R = 0, G = 1, B = 2;
bool solve(int n, const vector<array<bool, 3>> &a) {
bool col[3] = {};
vector<bool> num(n, false);
for (int c = 0; c < 3; ++c)
for (int i = 0; i < n; ++i) if (a[i][c]) col[c] = true, num[i] = true;
if (accumulate(num.begin(), num.end(), 0) == 1)
return true;
set<int> s[2][3];
for (int c1 = 0; c1 < 3; ++c1) {
for (int c2 = c1 + 1; c2 < 3; ++c2) {
for (int i = 0; i < n; ++i)
if (a[i][c1] && a[i][c2]) s[c1][c2].insert(i);
}
}
if (const int ex_sum = int(col[0]) + int(col[1]) + int(col[2]); ex_sum == 1)
return true;
else if (ex_sum == 2)
return !s[0][1].empty() || !s[0][2].empty() || !s[1][2].empty();
else {
if (int(s[0][1].empty()) + int(s[0][2].empty()) + int(s[1][2].empty()) >= 2)
return false;
if (s[0][1].size() > 1 || s[0][2].size() > 1 || s[1][2].size() > 1)
return true;
set<int> t;
if (!s[0][1].empty()) t.insert(*s[0][1].begin());
if (!s[0][2].empty()) t.insert(*s[0][2].begin());
if (!s[1][2].empty()) t.insert(*s[1][2].begin());
return t.size() > 1;
}
}
int main() {
int t; cin >> t;
while (t--) {
int n; cin >> n;
vector<array<bool, 3>> a(n);
for (int i = 0; i < n; ++i) {
char c; int d; cin >> c >> d;
a[d - 1][c == 'R' ? R : c == 'G' ? G : B] = true;
}
cout << (solve(n, a) ? "YES\n" : "NO\n");
}
}
t33f