結果

問題 No.133 カードゲーム
ユーザー 14番14番
提出日時 2016-04-17 19:17:44
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 3,119 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 107,120 KB
実行使用メモリ 24,696 KB
最終ジャッジ日時 2023-09-07 09:25:41
合計ジャッジ時間 4,770 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
22,732 KB
testcase_01 AC 58 ms
22,716 KB
testcase_02 AC 55 ms
22,560 KB
testcase_03 AC 52 ms
20,664 KB
testcase_04 AC 55 ms
22,668 KB
testcase_05 AC 56 ms
22,492 KB
testcase_06 AC 56 ms
22,812 KB
testcase_07 AC 58 ms
24,624 KB
testcase_08 AC 59 ms
22,544 KB
testcase_09 AC 56 ms
24,696 KB
testcase_10 AC 55 ms
22,632 KB
testcase_11 AC 54 ms
22,628 KB
testcase_12 AC 56 ms
24,588 KB
testcase_13 AC 58 ms
22,636 KB
testcase_14 AC 59 ms
22,508 KB
testcase_15 AC 55 ms
22,648 KB
testcase_16 AC 57 ms
22,648 KB
testcase_17 AC 53 ms
20,756 KB
testcase_18 AC 55 ms
22,736 KB
testcase_19 AC 54 ms
22,576 KB
testcase_20 AC 55 ms
22,624 KB
testcase_21 AC 57 ms
22,680 KB
testcase_22 AC 57 ms
22,740 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.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();
    }
}
0