結果

問題 No.24 数当てゲーム
ユーザー bayashiko_rbayashiko_r
提出日時 2018-11-07 00:41:52
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 2,088 bytes
コンパイル時間 2,431 ms
コンパイル使用メモリ 115,020 KB
実行使用メモリ 25,840 KB
最終ジャッジ日時 2024-04-30 22:21:09
合計ジャッジ時間 1,741 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,184 KB
testcase_01 AC 27 ms
23,936 KB
testcase_02 AC 27 ms
22,072 KB
testcase_03 AC 28 ms
23,996 KB
testcase_04 AC 27 ms
24,064 KB
testcase_05 AC 28 ms
24,192 KB
testcase_06 AC 27 ms
24,060 KB
testcase_07 AC 27 ms
25,840 KB
testcase_08 AC 27 ms
24,112 KB
testcase_09 AC 29 ms
24,060 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;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        //N行の入力
        string[] s = new string[N];
        int[] A = new int[N];
        int[] B = new int[N];
        int[] C = new int[N];
        int[] D = new int[N];
        string[] R = new string[N];
        for (int i = 0; i < N; i++) {
            s[i] = Console.ReadLine();
            A[i] = int.Parse(s[i].Split(' ')[0]);
            B[i] = int.Parse(s[i].Split(' ')[1]);
            C[i] = int.Parse(s[i].Split(' ')[2]);
            D[i] = int.Parse(s[i].Split(' ')[3]);
            R[i] = s[i].Split(' ')[4];
        }

        //回答となりうる数字のリスト
        List<int> ans = new List<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        
        //回答が一つになるまで続ける
        while(ans.Count != 1) {
            for (int i = 0; i < N; i++) {
                if (R[i] == "YES") {
                    List<int> temp = new List<int> {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
                    //6つの数字よりなる、取り除く数字のリストを作る
                    temp.Remove(A[i]);
                    temp.Remove(B[i]);
                    temp.Remove(C[i]);
                    temp.Remove(D[i]);
                    
                    //ansリストから、6つの数字を取り除く
                    for (int j = 0; j < 6; j++) {
                        if (ans.Contains(temp[j])){
                            ans.Remove(temp[j]);
                        }
                    }
                } else if (R[i] == "NO") {
                    //ansリストから、4つの数字を取り除く
                    if (ans.Contains(A[i])) ans.Remove(A[i]);
                    if (ans.Contains(B[i])) ans.Remove(B[i]);
                    if (ans.Contains(C[i])) ans.Remove(C[i]);
                    if (ans.Contains(D[i])) ans.Remove(D[i]);
                }
            }
        }
        //出力
        Console.WriteLine(ans[0]);
    }
}
0