結果

問題 No.11 カードマッチ
ユーザー 明智重蔵明智重蔵
提出日時 2015-09-12 06:14:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 2,866 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 116,688 KB
実行使用メモリ 29,568 KB
最終ジャッジ日時 2024-04-20 01:07:14
合計ジャッジ時間 1,975 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
27,404 KB
testcase_01 AC 29 ms
25,484 KB
testcase_02 AC 28 ms
25,424 KB
testcase_03 AC 30 ms
25,420 KB
testcase_04 AC 31 ms
25,420 KB
testcase_05 AC 30 ms
29,568 KB
testcase_06 AC 31 ms
25,424 KB
testcase_07 AC 30 ms
25,292 KB
testcase_08 AC 30 ms
27,396 KB
testcase_09 AC 30 ms
25,164 KB
testcase_10 AC 31 ms
25,552 KB
testcase_11 AC 31 ms
25,352 KB
testcase_12 AC 31 ms
25,420 KB
testcase_13 AC 30 ms
29,440 KB
testcase_14 AC 29 ms
25,268 KB
testcase_15 AC 30 ms
25,296 KB
testcase_16 AC 30 ms
25,420 KB
testcase_17 AC 30 ms
27,276 KB
testcase_18 AC 29 ms
27,520 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 = "Input5";

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

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            WillReturn.Add("5");
            WillReturn.Add("1");
            WillReturn.Add("1 1");
            //5
            //2種類のマークと5つの数字の組み合わせのトランプを使用する。
            //この場合
            //「マーク1の1以外の4種類」と、「マーク2の1」がマッチする。
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4");
            WillReturn.Add("13");
            WillReturn.Add("3");
            WillReturn.Add("1 1");
            WillReturn.Add("2 1");
            WillReturn.Add("2 5");
            //27
            //普通のトランプのセットと同様である。
            //この時マッチするのは
            //「マーク1の1以外」と「マーク2の1,5以外」と
            //「マーク3とマーク4の1と5」である。
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4");
            WillReturn.Add("13");
            WillReturn.Add("4");
            WillReturn.Add("1 5");
            WillReturn.Add("2 6");
            WillReturn.Add("3 7");
            WillReturn.Add("4 8");
            //48
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("3");
            WillReturn.Add("2");
            WillReturn.Add("2");
            WillReturn.Add("1 1");
            WillReturn.Add("2 1");
            //3
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct SKPairDef
    {
        internal int S;
        internal int K;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int W = int.Parse(InputList[0]);
        int H = int.Parse(InputList[1]);

        var SKPairList = new List<SKPairDef>();
        foreach (string EachStr in InputList.Skip(3)) {
            int[] wkArr = EachStr.Split(' ').Select(X => int.Parse(X)).ToArray();
            SKPairList.Add(new SKPairDef() { S = wkArr[0], K = wkArr[1] });
        }
        int[] DistinctSArr = SKPairList.Select(X => X.S).Distinct().ToArray();
        int[] DistinctKArr = SKPairList.Select(X => X.K).Distinct().ToArray();

        //n(A∪B) = n(A) + n(B) - n(A∩B)
        long Answer = DistinctSArr.Length * H + DistinctKArr.Length * W;
        Answer -= DistinctSArr.Length * DistinctKArr.Length;

        //既存の集合の分を引く
        Answer -= SKPairList.Count;

        Console.WriteLine(Answer);
    }
}
0