結果

問題 No.133 カードゲーム
ユーザー kakukakujirorikakukakujirori
提出日時 2021-08-09 17:45:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,038 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 11,940 KB
実行使用メモリ 42,452 KB
最終ジャッジ日時 2023-10-21 15:31:17
合計ジャッジ時間 14,845 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 485 ms
42,396 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 482 ms
42,396 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np
#from numba import njit, b1, i1, i4, i8, f8, jitclass
sys.setrecursionlimit(10**9)
from itertools import permutations

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def input(): return sys.stdin.readline().strip()
#"""
def from_read(dtype=np.int64):
    return np.fromstring(read().decode(), dtype=dtype, sep=' ')

def from_readline(dtype=np.int64):
    return np.fromstring(readline().decode(), dtype=dtype, sep=' ')
#"""

        
#@njit("(i8,i8,i8,i8[:],i8[:],)", cache=True)
def main(N, A, B):
    total = 1
    for i in range(1, N + 1): total *= i
    total *= total
    ans = 0
    for a in permutations(A, N):
        for b in permutations(B, N):
            win = 0
            for aa, bb in zip(a, b):
                win += 1 if aa > bb else 0
            ans += 1 if win > N // 2 else 0
    print(ans / total)
            

if __name__ == '__main__':
    N = int(input())
    A = from_readline()
    B = from_readline()
    main(N, A, B)
0