結果
| 問題 |
No.2148 ひとりUNO
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-15 20:20:47 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,027 bytes |
| コンパイル時間 | 1,213 ms |
| コンパイル使用メモリ | 114,496 KB |
| 実行使用メモリ | 36,436 KB |
| 最終ジャッジ日時 | 2024-12-29 11:51:48 |
| 合計ジャッジ時間 | 6,148 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 38 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
}
}