結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2016-02-09 05:59:22 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 33 ms / 5,000 ms |
コード長 | 3,229 bytes |
コンパイル時間 | 1,106 ms |
コンパイル使用メモリ | 109,184 KB |
実行使用メモリ | 19,456 KB |
最終ジャッジ日時 | 2024-06-25 03:42:28 |
合計ジャッジ時間 | 2,497 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
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 = "InputX";static List<string> GetInputList(){var WillReturn = new List<string>();if (InputPattern == "Input1") {WillReturn.Add("2");WillReturn.Add("2 4");WillReturn.Add("1 3");//0.5}else if (InputPattern == "Input2") {WillReturn.Add("2");WillReturn.Add("3 4");WillReturn.Add("1 2");//1}else if (InputPattern == "Input3") {WillReturn.Add("1");WillReturn.Add("1");WillReturn.Add("2");//0}else if (InputPattern == "Input4") {WillReturn.Add("3");WillReturn.Add("6 2 3");WillReturn.Add("1 5 4");//0.666667}else {string wkStr;while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);}return WillReturn;}static void Main(){List<string> InputList = GetInputList();int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();int[] BArr = InputList[2].Split(' ').Select(X => int.Parse(X)).ToArray();List<int[]> AJyunretu = DeriveJyunretu(AArr);List<int[]> BJyunretu = DeriveJyunretu(BArr);decimal TotalPatternCnt = AJyunretu.Count * BJyunretu.Count;decimal WinAPatternCnt = 0;foreach (int[] EachA in AJyunretu) {foreach (int[] EachB in BJyunretu) {int WinCnt = 0;int LoseCnt = 0;for (int I = 0; I <= AArr.GetUpperBound(0); I++) {if (EachA[I] > EachB[I]) WinCnt++;if (EachA[I] < EachB[I]) LoseCnt++;}if (WinCnt > LoseCnt) WinAPatternCnt++;}}Console.WriteLine(WinAPatternCnt / TotalPatternCnt);}struct JyoutaiDef{internal List<int> SelectedIndList;}//深さ優先探索で順列を列挙static List<int[]> DeriveJyunretu(int[] pArr){var WillReturn = new List<int[]>();var stk = new Stack<JyoutaiDef>();JyoutaiDef WillPush;WillPush.SelectedIndList = new List<int>();stk.Push(WillPush);while (stk.Count > 0) {JyoutaiDef Popped = stk.Pop();//クリア判定if (Popped.SelectedIndList.Count == pArr.Length) {int[] wkArr = new int[pArr.Length];for (int I = 0; I <= wkArr.GetUpperBound(0); I++) {wkArr[I] = pArr[Popped.SelectedIndList[I]];}WillReturn.Add(wkArr);continue;}for (int I = 0; I <= pArr.GetUpperBound(0); I++) {if (Popped.SelectedIndList.Contains(I)) continue;WillPush.SelectedIndList = new List<int>(Popped.SelectedIndList);WillPush.SelectedIndList.Add(I);stk.Push(WillPush);}}return WillReturn;}}