結果

問題 No.133 カードゲーム
コンテスト
ユーザー lloyz
提出日時 2023-06-23 00:40:07
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 97 ms / 5,000 ms
コード長 530 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 610 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2026-03-20 01:33:23
合計ジャッジ時間 3,897 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from itertools import permutations

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
fact = 1
for i in range(1, n + 1):
    fact *= i
for P1 in permutations(range(n)):
    for P2 in permutations(range(n)):
        C = [0, 0]
        for i in range(n):
            p1i, p2i = P1[i], P2[i]
            if A[p1i] > B[p2i]:
                C[0] += 1
            elif A[p1i] < B[p2i]:
                C[1] += 1
        if C[0] > C[1]:
            ans += 1
ans /= fact * fact
print(ans)
0