結果
| 問題 |
No.2148 ひとりUNO
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-05 10:46:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,496 bytes |
| コンパイル時間 | 4,235 ms |
| コンパイル使用メモリ | 254,276 KB |
| 最終ジャッジ日時 | 2025-02-09 05:23:41 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 39 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i)
bool query() {
int n;
cin >> n;
vi cnt(3);
vector c(3, vector<bool>(n, false));
rep(i, n) {
char ch;
int x;
cin >> ch >> x, x--;
c[ch % 3][x] = true;
cnt[ch % 3]++;
}
int con01 = 0, con02 = 0, con12 = 0, con123 = 0;
rep(i, n) {
if (c[0][i] && c[1][i] && c[2][i]) {
if (con123 > 0) return true;
con123 |= 1;
} else {
if (c[0][i] && c[1][i]) con01 |= 1;
if (c[0][i] && c[2][i]) con02 |= 1;
if (c[1][i] && c[2][i]) con12 |= 1;
}
if (con01 + con02 + con12 + con123 >= 2) return true;
}
if (con01 > 0) return cnt[2] == 0;
if (con02 > 0) return cnt[1] == 0;
if (con12 > 0) return cnt[0] == 0;
if (con123 > 0) {
if (cnt[0] == 1) return true;
if (cnt[1] == 1) return true;
if (cnt[2] == 1) return true;
}
int nz = 0;
rep(i, 3) {
if (cnt[i] > 0) nz++;
}
return nz == 1;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
cout << (query() ? "Yes" : "No") << '\n';
}
return 0;
}