結果

問題 No.2148 ひとりUNO
ユーザー lddlinanlddlinan
提出日時 2023-03-23 02:08:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,370 bytes
コンパイル時間 879 ms
コンパイル使用メモリ 86,504 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 19:18:43
合計ジャッジ時間 2,768 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
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 AC 13 ms
4,348 KB
testcase_17 AC 13 ms
4,348 KB
testcase_18 AC 13 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 13 ms
4,348 KB
testcase_22 AC 13 ms
4,348 KB
testcase_23 AC 13 ms
4,348 KB
testcase_24 AC 13 ms
4,348 KB
testcase_25 AC 13 ms
4,348 KB
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 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
class mypcmp {
public:
    bool operator()(const int& a, const int& b) {
        return a<b;
    }
};


char mk[200004];
int qq[200004];
int main() {
    int n, i, v, h=0, x3, x5, x6, x7;
    char ib[8], c;
    int cs[4];
    memset(mk, 0, sizeof(mk));
    int tc; scanf("%d", &tc); while(tc) { tc--;
        for (i=0; i<h; i++) mk[qq[i]]=0;
        scanf("%d", &n);
        cs[0]=cs[1]=cs[2]=0;
        h=0; for (i=0; i<n; i++) {
            scanf("%s %d", ib, &v);
            if (ib[0]=='B') c=0; else if (ib[0]=='G') c=1; else c=2;
            cs[c]++;
            mk[v]|=(1<<c);
            qq[h++]=v; 
        }
        x3=0; for (i=0; i<h; i++) if ((mk[qq[i]]&3)==3) x3++;
        x5=0; for (i=0; i<h; i++) if ((mk[qq[i]]&5)==5) x5++;
        x6=0; for (i=0; i<h; i++) if ((mk[qq[i]]&6)==6) x6++;
        x7=0; for (i=0; i<h; i++) if ((mk[qq[i]]&7)==7) x7++;
        if (cs[0]==0) {
            if (cs[1]==0||cs[2]==0) printf("YES\n");
            else {
                // 1, 2
                if (x6) printf("YES\n"); else printf("NO\n");
            }
        } else {
            if (cs[1]==0&&cs[2]==0) printf("YES\n");
            else if (cs[1]==0) {
                //0, 2
                if (x5) printf("YES\n"); else printf("NO\n");
            } else if (cs[2]==0) {
                //0, 1
                if (x3) printf("YES\n"); else printf("NO\n");
            } else {
                if (x3>1) {
                    if (x5||x6) printf("YES\n"); else printf("NO\n");
                    continue;
                }
                if (x5>1) {
                    if (x3||x6) printf("YES\n"); else printf("NO\n");
                    continue;
                }
                if (x6>1) {
                    if (x3||x5) printf("YES\n"); else printf("NO\n");
                    continue;
                }
                if (x3==0&&x5==0) { printf("NO\n"); continue; }
                if (x3==0&&x6==0) { printf("NO\n"); continue; }
                if (x5==0&&x6==0) { printf("NO\n"); continue; }
                // one link
                if (x7==0) { printf("YES\n"); continue; }
                // 0->1->2
                if (x3&&x6) {
                    if (cs[1]==1) { printf("YES\n"); continue; }
                }
                // 0->2->1
                if (x5&&x6) {
                    if (cs[2]==1) { printf("YES\n"); continue; }
                }
                // 1->0->2
                if (x3&&x5) {
                    if (cs[1]==1) { printf("YES\n"); continue; }
                }
                // 1->2->0
                if (x6&&x5) {
                    if (cs[2]==1) { printf("YES\n"); continue; }
                }
                // 2->0->1
                if (x5&&x3) {
                    if (cs[0]==1) { printf("YES\n"); continue; }
                }
                // 2->1->0
                if (x6&&x3) {
                    if (cs[1]==1) { printf("YES\n"); continue; }
                }
                printf("NO\n");
            }
        }
    }
    return 0;
}
0