結果

問題 No.24 数当てゲーム
ユーザー 明智重蔵明智重蔵
提出日時 2015-10-31 18:20:52
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 2,250 bytes
コンパイル時間 3,397 ms
コンパイル使用メモリ 107,164 KB
実行使用メモリ 25,052 KB
最終ジャッジ日時 2023-10-11 07:15:56
合計ジャッジ時間 4,250 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
25,052 KB
testcase_01 AC 73 ms
22,972 KB
testcase_02 AC 74 ms
23,084 KB
testcase_03 AC 73 ms
23,088 KB
testcase_04 AC 73 ms
22,852 KB
testcase_05 AC 73 ms
22,968 KB
testcase_06 AC 73 ms
23,072 KB
testcase_07 AC 73 ms
22,984 KB
testcase_08 AC 74 ms
25,020 KB
testcase_09 AC 74 ms
22,848 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("1 2 4 3 NO");
            WillReturn.Add("8 5 6 7 NO");
            WillReturn.Add("0 1 2 3 NO");
            //9
            //0から8までの中に含まれていないので、残りの9が答えです
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2");
            WillReturn.Add("1 2 3 4 YES");
            WillReturn.Add("4 5 6 7 YES");
            //4
            //1,2,3,4と4,5,6,7の中で重複している数字は4だけなので、答えが確定します
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4");
            WillReturn.Add("2 6 5 3 NO");
            WillReturn.Add("1 0 4 7 YES");
            WillReturn.Add("1 7 8 4 YES");
            WillReturn.Add("7 1 9 8 NO");
            //4
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct SyuugouInfo
    {
        internal IEnumerable<int> NumEnum;
        internal string Result;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        var SyuugouInfoList = new List<SyuugouInfo>();
        foreach (string EachStr in InputList.Skip(1)) {
            string[] wkArr = EachStr.Split(' ').ToArray();

            SyuugouInfo WillAdd;
            WillAdd.NumEnum = wkArr.Take(4).Select(X => int.Parse(X));
            WillAdd.Result = wkArr.Last();
            SyuugouInfoList.Add(WillAdd);
        }

        var NumSet = new HashSet<int>(Enumerable.Range(0, 10));
        foreach (SyuugouInfo EachSyuugouInfo in SyuugouInfoList) {
            if (EachSyuugouInfo.Result == "YES")
                NumSet.IntersectWith(EachSyuugouInfo.NumEnum);
            if (EachSyuugouInfo.Result == "NO")
                NumSet.ExceptWith(EachSyuugouInfo.NumEnum);
        }
        Console.WriteLine(NumSet.First());
    }
}
0