結果
問題 |
No.133 カードゲーム
|
ユーザー |
![]() |
提出日時 | 2019-09-19 17:49:04 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 28 ms / 5,000 ms |
コード長 | 1,197 bytes |
コンパイル時間 | 193 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-07-19 10:37:29 |
合計ジャッジ時間 | 1,624 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
from math import factorial import sys sys.setrecursionlimit(100000) used1 = [] used2 = [] n = 0 ap = [] bp = [] a, b = ([], []) def rec2(pos): ans = 0 if pos == n: # a, b の勝ち数 aa, bb = (0, 0) for x, y in zip(ap, bp): if a[x] > b[y]: aa += 1 elif a[x] < b[y]: bb += 1 return 1 if aa > bb else 0 for i in range(n): if not used2[i]: bp.append(i) used2[i] = True ans += rec2(pos+1) used2[i] = False bp.pop() return ans def rec1(pos): ans = 0 if pos == n: # return rec2(0, a, b) return rec2(0) for i in range(n): if not used1[i]: used1[i] = True ap.append(i) ans += rec1(pos+1) ap.pop() used1[i] = False return ans def main(): global used1, used2, n, a, b n = int(input()) used1 = [False for i in range(n)] used2 = [False for i in range(n)] a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] print(rec1(0)/factorial(n)**2) if __name__ == '__main__': main()