結果

問題 No.2148 ひとりUNO
ユーザー 👑 kakel-sankakel-san
提出日時 2023-01-15 20:20:47
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,027 bytes
コンパイル時間 1,082 ms
コンパイル使用メモリ 68,504 KB
実行使用メモリ 32,944 KB
最終ジャッジ日時 2023-08-28 12:42:42
合計ジャッジ時間 7,011 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
24,596 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 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 AC 65 ms
22,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var t = int.Parse(ReadLine());
        var ans = new bool[t];
        for (var u = 0; u < t; ++u)
        {
            var n = int.Parse(ReadLine());
            var map = SList(n);
            var b = new HashSet<int>();
            var g = new HashSet<int>();
            var r = new HashSet<int>();
            foreach (var card in map)
            {
                var d = int.Parse(card.Substring(2));
                if (card[0] == 'B') b.Add(d);
                else if (card[0] == 'G') g.Add(d);
                else r.Add(d);
            }
            if (Check(b, g, r)) ans[u] = true;
            else if (Check(b, r, g)) ans[u] = true;
            else if (Check(r, b, g)) ans[u] = true;
            else if (Check(r, g, b)) ans[u] = true;
            else if (Check(g, b, r)) ans[u] = true;
            else if (Check(g, r, b)) ans[u] = true;
        }
        WriteLine(string.Join("\n", ans.Select(f => f ? "YES" : "NO")));
    }
    static bool Check(HashSet<int> list1, HashSet<int> list2, HashSet<int> list3)
    {
        if (list2.Count > 0)
        {
            var f12 = new HashSet<int>();
            var f23 = new HashSet<int>();
            foreach (var li in list2)
            {
                if (list1.Contains(li)) f12.Add(li);
                if (list3.Contains(li)) f23.Add(li);
            }
            if (list3.Count == 0 || f12.Count > 0) return true;
            if (list3.Count > 0)
            {
                foreach (var f2 in f12) if (f23.Count - (f23.Contains(f2) ? 1 : 0) > 0) return true;
            }
        }
        else if (list3.Count == 0) return true;
        return false;
    }
}
0