結果
| 問題 | No.133 カードゲーム |
| コンテスト | |
| ユーザー |
nanophoto12
|
| 提出日時 | 2015-01-28 01:19:11 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,128 bytes |
| 記録 | |
| コンパイル時間 | 3,985 ms |
| コンパイル使用メモリ | 112,912 KB |
| 実行使用メモリ | 30,240 KB |
| 最終ジャッジ日時 | 2024-10-07 02:55:27 |
| 合計ジャッジ時間 | 2,078 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 2 WA * 17 |
コンパイルメッセージ
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;
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));
}
}
}
nanophoto12