結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2016-04-17 19:17:44 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 30 ms / 5,000 ms |
コード長 | 3,119 bytes |
コンパイル時間 | 1,092 ms |
コンパイル使用メモリ | 107,648 KB |
実行使用メモリ | 18,944 KB |
最終ジャッジ日時 | 2024-06-25 03:43:38 |
合計ジャッジ時間 | 2,367 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int cardCount = int.Parse(Reader.ReadLine()); int[] cardA = Reader.GetInt(); int[] cardB = Reader.GetInt(); List<List<int>> listA = this.getKumiawase(new List<int>(cardA)); List<List<int>> listB = this.getKumiawase(new List<int>(cardB)); int aWin = 0; int bWin = 0; int even = 0; listA.ForEach((a)=>{ listB.ForEach((b)=>{ int cntA = 0; int cntB = 0; for(int i=0; i<a.Count; i++) { if(a[i] > b[i]) { cntA++; } else if(a[i] < b[i]) { cntB++; } } if(cntA > cntB) { aWin++; } else if(cntB > cntA) { bWin++; } else { even++; } }); }); double ans = aWin / (double)(bWin+even+aWin); Console.WriteLine(ans); } private List<List<int>> getKumiawase(List<int> target) { List<List<int>> ans = new List<List<int>>(); if(target.Count == 0) { ans.Add(new List<int>()); ans[0].AddRange(target); return ans; } for(int i=0; i<target.Count; i++) { List<int> subTarget = new List<int>(target); subTarget.RemoveAt(i); List<List<int>> tmp = this.getKumiawase(subTarget); foreach (List<int> ansItem in tmp) { List<int> item = new List<int>(ansItem); item.Insert(0, target[i]); ans.Add(item); } } return ans; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 3 6 2 3 1 5 4 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }