結果
問題 | No.11 カードマッチ |
ユーザー | 明智重蔵 |
提出日時 | 2015-09-12 06:14:50 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 33 ms / 5,000 ms |
コード長 | 2,866 bytes |
コンパイル時間 | 901 ms |
コンパイル使用メモリ | 113,480 KB |
実行使用メモリ | 19,456 KB |
最終ジャッジ日時 | 2024-10-11 19:54:48 |
合計ジャッジ時間 | 2,214 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
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 = "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);}}