結果

問題 No.24 数当てゲーム
ユーザー takosamatakosama
提出日時 2017-12-16 22:23:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 67 ms / 5,000 ms
コード長 2,206 bytes
コンパイル時間 2,351 ms
コンパイル使用メモリ 108,892 KB
実行使用メモリ 24,004 KB
最終ジャッジ日時 2023-08-21 11:15:58
合計ジャッジ時間 3,624 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
21,956 KB
testcase_01 AC 65 ms
21,868 KB
testcase_02 AC 67 ms
24,004 KB
testcase_03 AC 66 ms
21,900 KB
testcase_04 AC 65 ms
21,832 KB
testcase_05 AC 66 ms
24,004 KB
testcase_06 AC 67 ms
21,820 KB
testcase_07 AC 66 ms
21,888 KB
testcase_08 AC 66 ms
23,916 KB
testcase_09 AC 65 ms
21,860 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.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace yukicore
{
    //this algorithm think by claclator
    class Element
    {
        public int[] nums;
        public Element(int[] nums) => this.nums = nums;
        public Element(Element e) => this.nums = e.nums;

        public static Element operator -(Element a, Element b)
        {
            var rtn = new List<int>();
            foreach (var num in a.nums)
            {
                if (b.nums.All(x => x != num))
                    rtn.Add(num);
            }
            return new Element(rtn.ToArray());
        }

        public static Element operator +(Element a, Element b)
        {
            var rtn = new List<int>();
            rtn.AddRange(a.nums);
            rtn.AddRange(b.nums);
            return new Element(rtn.Distinct().ToArray());
        }

        public static Element operator *(Element a, Element b)
        {
            var rtn = new List<int>();
            foreach (var num in a.nums)
            {
                if (b.nums.Contains(num))
                    rtn.Add(num);
            }
            return new Element(rtn.ToArray());
        }
    }

    internal class Program
    {
        private static void Main(string[] args)
        {
            Element mother = new Element(Enumerable.Range(0, 10).ToArray());
            Element rtn = new Element(Enumerable.Range(0, 10).ToArray());
            Console.ReadLine();
            while (true)
            {

                var tmp = Console.ReadLine();
                if (tmp == null || tmp == "") break;
                var spl = tmp.Split(' ');
                var inputs = spl.Take(4).Select(x => int.Parse(x)).ToArray();
                var flag = spl.Last() == "YES" ? true : false;
                Element input;
                if (flag)
                    input = new Element(inputs);
                else
                    input = new Element(mother - new Element(inputs));
                rtn *= input;
            }

            Console.WriteLine(
                rtn.nums[0]);
        }
    }

}
0