結果

問題 No.133 カードゲーム
ユーザー niodachi1niodachi1
提出日時 2019-09-03 15:59:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 563 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2023-08-25 18:52:32
合計ジャッジ時間 1,961 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,308 KB
testcase_01 AC 15 ms
8,284 KB
testcase_02 AC 16 ms
8,308 KB
testcase_03 AC 16 ms
8,132 KB
testcase_04 AC 16 ms
8,320 KB
testcase_05 AC 16 ms
8,172 KB
testcase_06 AC 16 ms
8,124 KB
testcase_07 AC 17 ms
8,236 KB
testcase_08 AC 16 ms
8,296 KB
testcase_09 AC 16 ms
8,244 KB
testcase_10 AC 17 ms
8,256 KB
testcase_11 AC 16 ms
8,220 KB
testcase_12 AC 16 ms
8,256 KB
testcase_13 AC 16 ms
8,308 KB
testcase_14 AC 15 ms
8,276 KB
testcase_15 AC 16 ms
8,116 KB
testcase_16 AC 17 ms
8,136 KB
testcase_17 AC 17 ms
8,172 KB
testcase_18 AC 17 ms
8,172 KB
testcase_19 AC 17 ms
8,244 KB
testcase_20 AC 16 ms
8,132 KB
testcase_21 AC 16 ms
8,116 KB
testcase_22 AC 16 ms
8,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

N = int(input())
A = "".join(list(map(str, input().split())))
B = "".join(list(map(str, input().split())))

a = []
b = []
for i in itertools.permutations(A):
	a.append(i)
for i in itertools.permutations(B):
	b.append(i)

a_win = 0
for i in range(len(a)):
	for j in range(len(b)):
		
		set_a = 0
		set_b = 0

		for k in range(N):
			if a[i][k] > b[j][k]:
				set_a+=1
			elif a[i][k] < b[j][k]:
				set_b+=1
		if set_a > set_b:
			a_win += 1
def num_game(n):
	if n == 1:
		return 1
	return n * num_game(n-1)

num = num_game(N)
print(a_win/num**2)
0