結果

問題 No.133 カードゲーム
ユーザー MinoruTazakuraMinoruTazakura
提出日時 2020-04-03 01:46:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 999 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 11,016 KB
実行使用メモリ 8,872 KB
最終ジャッジ日時 2023-09-11 01:58:08
合計ジャッジ時間 1,654 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,644 KB
testcase_01 AC 21 ms
8,672 KB
testcase_02 AC 20 ms
8,676 KB
testcase_03 AC 21 ms
8,724 KB
testcase_04 AC 20 ms
8,684 KB
testcase_05 AC 22 ms
8,816 KB
testcase_06 AC 22 ms
8,872 KB
testcase_07 AC 22 ms
8,708 KB
testcase_08 AC 20 ms
8,708 KB
testcase_09 AC 21 ms
8,812 KB
testcase_10 AC 21 ms
8,684 KB
testcase_11 AC 21 ms
8,672 KB
testcase_12 AC 21 ms
8,776 KB
testcase_13 AC 20 ms
8,648 KB
testcase_14 AC 21 ms
8,752 KB
testcase_15 AC 20 ms
8,708 KB
testcase_16 AC 21 ms
8,684 KB
testcase_17 AC 22 ms
8,720 KB
testcase_18 AC 21 ms
8,680 KB
testcase_19 AC 21 ms
8,708 KB
testcase_20 AC 21 ms
8,828 KB
testcase_21 AC 22 ms
8,772 KB
testcase_22 AC 21 ms
8,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import sys
# readline = sys.stdin.buffer.readline

from collections import deque
from copy import copy,deepcopy
from itertools import permutations,combinations

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

n = int(input())
a = list(myinput())
b = list(myinput())

pa = list(permutations(a))
pb = list(permutations(b))
# print(pa)
# print(pb)

count_win_a = 0
count_win_b = 0
count_match = 0
for pattern_a in pa:
    for pattern_b in pb:
        count_match += 1
        count_a = 0
        count_b = 0
        for i in range(n):
            card_a = pattern_a[i]
            card_b = pattern_b[i]
            if card_a > card_b:
                count_a += 1
            else:
                count_b += 1
        if count_a > count_b:
            count_win_a += 1
        elif count_a==count_b:
            pass
        else:
            count_win_b += 1
# print(count_win_a,count_match)
ans = count_win_a/count_match
print(ans)
0