結果

問題 No.133 カードゲーム
ユーザー nanophoto12nanophoto12
提出日時 2015-01-28 01:19:11
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,128 bytes
コンパイル時間 3,593 ms
コンパイル使用メモリ 111,256 KB
実行使用メモリ 28,324 KB
最終ジャッジ日時 2024-04-16 10:10:21
合計ジャッジ時間 4,064 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
26,032 KB
testcase_01 AC 31 ms
26,132 KB
testcase_02 AC 32 ms
28,068 KB
testcase_03 AC 30 ms
27,404 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 30 ms
25,628 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Text;

namespace YukiCoder2
{
    class Program
    {
        public static bool NextPermutation<T>(T[] array, int start, int length)
            where T : IComparable
        {
            int end = start + length - 1;

            if (end <= start) return false;

            int last = end;
            while (true)
            {
                int pos = last--;

                if (array[last].CompareTo(array[pos]) < 0)
                {
                    int i;
                    for (i = end + 1; array[last].CompareTo(array[--i]) >= 0; ) { }
                    T tmp = array[last]; array[last] = array[i]; array[i] = tmp;
                    Array.Reverse(array, pos, end - pos + 1);
                    return true;
                }
                if (last == start)
                {
                    Array.Reverse(array, start, end - start);
                    return false;
                }
            }

            throw new Exception("NextPermutation: Fatal error");
        }

        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = line[0];
            var aCards = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var bCards = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int sum = 0;
            do
            {
                var bCopy = bCards.ToArray();
                do
                {
                    int win = 0;
                    for (int i = 0; i < n; i++)
                    {
                        if (aCards[i] > bCards[i])
                        {
                            win++;
                        }
                    }
                    if (win > n / 2)
                    {
                        sum++;
                    }
                    
                } while (NextPermutation(bCopy, 0, n));
            } while (NextPermutation(aCards, 0, n));

            Console.WriteLine(sum/(double)(n*n));
        }
    }
}
0