結果

問題 No.24 数当てゲーム
コンテスト
ユーザー 大谷祐翔
提出日時 2025-11-04 13:47:28
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 2,110 bytes
コンパイル時間 7,413 ms
コンパイル使用メモリ 167,788 KB
実行使用メモリ 188,512 KB
最終ジャッジ日時 2025-11-04 13:47:38
合計ジャッジ時間 8,850 ms
ジャッジサーバーID
(参考情報)
judge7 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (104 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #
raw source code

class Program
{
    static void Main(string[] args)
    {
        string inputTurn = Console.ReadLine()!;
        int turn = int.Parse(inputTurn);
        List<string> yesList = new List<string>();
        List<string> noList = new List<string>();

        for (int i = 0; i < turn; i++)
        {
            string[] inputNum = Console.ReadLine()!.Split(' ');

            if (inputNum[4] == "YES")
            {
                for (int j = 0; j < 4; j++)
                {
                    yesList.Add(inputNum[j]);
                }
            }
            else
            {
                for (int j = 0; j < 4; j++)
                {
                    noList.Add(inputNum[j]);
                }
            }
        }

        yesList.Sort();
        List<string> duplicateList = new List<string>();
        if (yesList.Count > 5)
        {
            for (int i = 1; i < yesList.Count; i++)
            {
                if (yesList[i - 1] == yesList[i])
                {
                    duplicateList.Add(yesList[i]);
                }
            }
        }
        else
        {
            for (int i = 0; i < yesList.Count; i++)
            {
                duplicateList.Add(yesList[i]);
            }
        }

        List<string> notIncluded = new List<string>();
        HashSet<string> listSet = new HashSet<string>(noList);

        for (int i = 0; i <= 9; i++)
        {
            if (!listSet.Contains(i.ToString()))
            {
                notIncluded.Add(i.ToString());
            }
        }

        if (noList.Count == 0)
        {
            Console.WriteLine(duplicateList[0]);
        }
        else if (yesList.Count == 0)
        {
            Console.WriteLine(notIncluded[0]);
        }
        else
        {
            listSet = new HashSet<string>(notIncluded);
            for (int i = 0; i < duplicateList.Count; i++)
            {
                if (listSet.Contains(duplicateList[i]))
                {
                    Console.WriteLine(duplicateList[i]);
                    break;
                }
            }
        }

    }
}
0