結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
Toru
|
| 提出日時 | 2020-07-21 17:20:06 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 35 ms / 5,000 ms |
| コード長 | 1,510 bytes |
| コンパイル時間 | 224 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-12-30 01:48:07 |
| 合計ジャッジ時間 | 2,157 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
## import
from collections import deque # キュー、スタックに利用
import itertools
import math # 数学的計算に利用
# import numpy as np # 行列計算などに利用 # Pypy3ではimport不可
import sys
## 初期設定
# input = sys.stdin.readline # 標準入力の高速化に利用
sys.setrecursionlimit(10**7) # 再帰関数の呼び出し上限を増やす
inf = float('inf')
is_debug = False
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
def main():
'''メイン処理'''
# 1. A, Bのすべての順列を作成し、それぞれの順列で勝ち負けを判定
A_perm = [list(permutation) for permutation in itertools.permutations(A)]
B_perm = [list(permutation) for permutation in itertools.permutations(B)]
if is_debug:
print(A_perm)
print(B_perm)
num_games = len(A_perm) * len(B_perm)
num_A_win_games = 0
for aa in A_perm:
for bb in B_perm:
num_a_win = 0
num_b_win = 0
for a,b in zip(aa,bb):
if a > b:
num_a_win += 1
elif a < b:
num_b_win += 1
if num_a_win > num_b_win:
num_A_win_games += 1
if is_debug:
print(aa, bb)
if is_debug:
print(num_A_win_games, num_games)
print(num_A_win_games/num_games)
if __name__ == "__main__":
# ファイル実行時に、main()関数を実行
main()
Toru