結果
| 問題 | No.24 数当てゲーム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-10-22 09:32:37 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 2,266 bytes | 
| コンパイル時間 | 2,485 ms | 
| コンパイル使用メモリ | 107,136 KB | 
| 実行使用メモリ | 19,072 KB | 
| 最終ジャッジ日時 | 2024-11-21 13:35:55 | 
| 合計ジャッジ時間 | 2,241 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 8 RE * 2 | 
コンパイルメッセージ
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;
namespace yukicode {
    public class Program {
        public static void GetFirstPrediction(ref List<uint> nums, ref string answer, ref List<uint> prediction) {
            if (answer == "YES") prediction = nums;
            else {
                for (uint i = 1; i <= 9; ++i) {
                    if (nums.IndexOf( i ) == -1) prediction.Add( i );
                }
            }
        }
        public static void Predict(ref List<uint> nums, ref string answer, ref List<uint> prediction) {
            if (answer == "YES") {
                prediction = prediction.Intersect( nums ).ToList();
            } else {
                prediction = prediction.Except( nums ).ToList();
            }
        }
        public static uint Solver(System.IO.TextReader reader) {
            uint n = uint.Parse( reader.ReadLine() );
            var possibleNumbers = new List<uint>();
            for (var i = 0; i != n; ++i) {
                var buf = reader.ReadLine().Split();
                var nums = buf.Take( 4 ).ToList().ConvertAll( uint.Parse );
                if (i == 0) {
                    GetFirstPrediction( ref nums, ref buf[ 4 ], ref possibleNumbers );
                } else { 
                    Predict( ref nums, ref buf[ 4 ], ref possibleNumbers );
                }
            }
            return possibleNumbers[0];
        }
        private static void Main() {
            Console.WriteLine( Solver( Console.In ) );
        }
    }
    //--- MyLib ---
    public class MyLib {
        public static string Ordinalization(int num) {
            string surfix = "stndrdth";
            return string.Format( "{0}{1}", num,
                ( 0 < num % 10 && num % 10 <= 4 ) && ( ( num % 100 ) / 10 != 1 ) ?
                surfix.Substring( ( num % 10 - 1 ) * 2, 2 ) : surfix.Substring( 6 ) );
        }
        public static List<int> GetIntList(string input, char delimitor) {
            return input.Split( delimitor ).ToList<string>().ConvertAll<int>( int.Parse );
        }
        public static List<int> GetIntList(string input, char[] delimitors) {
            return input.Split( delimitors ).ToList<string>().ConvertAll<int>( int.Parse );
        }
    }
}
            
            
            
        