結果

問題 No.2148 ひとりUNO
ユーザー baLoon8128baLoon8128
提出日時 2022-12-05 10:46:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,496 bytes
コンパイル時間 4,621 ms
コンパイル使用メモリ 257,564 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 13:19:51
合計ジャッジ時間 6,212 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0