結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2015-01-22 23:35:36 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 5,000 ms |
| コード長 | 1,707 bytes |
| コンパイル時間 | 1,105 ms |
| コンパイル使用メモリ | 116,008 KB |
| 実行使用メモリ | 18,944 KB |
| 最終ジャッジ日時 | 2024-06-25 03:26:21 |
| 合計ジャッジ時間 | 2,509 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
using System.Collections.Generic;
class TEST{
static void Main(){
Sol mySol =new Sol();
mySol.Solve();
}
}
class Sol{
public void Solve(){
int[] C=new int[N];
for(int i=0;i<N;i++)C[i]=i;
List<int[]> L=new List<int[]>();
do{
L.Add((int[])C.Clone());
}while(NextPermutaion(C));
int cnt=0;int wina=0;
for(int i=0;i<L.Count;i++){
for(int j=0;j<L.Count;j++){
cnt++;
int a=0;int b=0;
for(int k=0;k<N;k++){
if(A[L[i][k]]>B[L[j][k]])a++;
if(A[L[i][k]]<B[L[j][k]])b++;
}
if(a>b)wina++;
}
}
Console.WriteLine("{0}",(double)wina/(double)cnt);
}
int N;
int[] A;
int[] B;
public Sol(){
N=ri();
A=ria();
B=ria();
}
static public bool NextPermutaion<T>(T[] A)where T:IComparable<T>{
for(int i=A.Length-2;i>=0;i--){
if(A[i].CompareTo(A[i+1])<0){
int trgt=Array.FindLastIndex(A,x=>A[i].CompareTo(x)<0);
Swap(ref A[i],ref A[trgt]);
Array.Reverse(A,i+1,A.Length-(i+1));
return true;
}
}
Array.Reverse(A);
return false;
}
static void Swap<T>(ref T x, ref T y){
T t=x;x=y;y=t;
}
static String rs(){return Console.ReadLine();}
static int ri(){return int.Parse(Console.ReadLine());}
static long rl(){return long.Parse(Console.ReadLine());}
static double rd(){return double.Parse(Console.ReadLine());}
static String[] rsa(){return Console.ReadLine().Split(' ');}
static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
kuuso1