結果
| 問題 | No.24 数当てゲーム | 
| コンテスト | |
| ユーザー |  明智重蔵 | 
| 提出日時 | 2015-10-31 18:20:52 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 40 ms / 5,000 ms | 
| コード長 | 2,250 bytes | 
| コンパイル時間 | 925 ms | 
| コンパイル使用メモリ | 113,676 KB | 
| 実行使用メモリ | 28,544 KB | 
| 最終ジャッジ日時 | 2024-09-13 06:25:02 | 
| 合計ジャッジ時間 | 1,906 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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());
    }
}
            
            
            
        