結果

問題 No.133 カードゲーム
ユーザー kuuso1kuuso1
提出日時 2015-01-22 23:35:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 72 ms / 5,000 ms
コード長 1,707 bytes
コンパイル時間 2,651 ms
コンパイル使用メモリ 106,748 KB
実行使用メモリ 24,864 KB
最終ジャッジ日時 2023-09-07 09:08:09
合計ジャッジ時間 5,199 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
22,636 KB
testcase_01 AC 68 ms
22,696 KB
testcase_02 AC 67 ms
24,624 KB
testcase_03 AC 63 ms
20,840 KB
testcase_04 AC 71 ms
22,764 KB
testcase_05 AC 72 ms
22,804 KB
testcase_06 AC 71 ms
22,628 KB
testcase_07 AC 70 ms
22,596 KB
testcase_08 AC 71 ms
22,800 KB
testcase_09 AC 71 ms
24,804 KB
testcase_10 AC 68 ms
24,624 KB
testcase_11 AC 70 ms
24,864 KB
testcase_12 AC 70 ms
24,632 KB
testcase_13 AC 67 ms
22,696 KB
testcase_14 AC 69 ms
22,760 KB
testcase_15 AC 69 ms
24,764 KB
testcase_16 AC 68 ms
22,612 KB
testcase_17 AC 64 ms
20,852 KB
testcase_18 AC 67 ms
22,672 KB
testcase_19 AC 69 ms
20,632 KB
testcase_20 AC 69 ms
22,784 KB
testcase_21 AC 69 ms
22,664 KB
testcase_22 AC 68 ms
22,696 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;
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));}
}
0