結果

問題 No.133 カードゲーム
ユーザー oosakik
提出日時 2019-09-22 19:13:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 871 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-09-19 03:43:04
合計ジャッジ時間 1,620 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

def run():
  N = int(input())
  A_list = list(map(int, input().split()))
  B_list = list(map(int, input().split()))
  array_A_list = array(A_list, N)
  array_B_list = array(B_list, N)
  #print(array_A_list)
  num_win = 0
  total = 0
  for a_list in array_A_list:
    for b_list in array_B_list:
      sub_total = 0
      total += 1
      #print(a_list, b_list)
      for a, b in zip(a_list, b_list):
        if a > b: sub_total += 1
      if sub_total > N//2:
        num_win += 1
  print(num_win/total)
  #print(num_win, total)

def add(pre_list, n_list):
  new_list = []
  for pre in pre_list:
    for n in n_list:
      if (n in pre) == False:
        new_list.append(pre+[n])
  return new_list

def array(n_list, N):
  res_list = [[n] for n in n_list]
  for n in range(N-1):
    res_list = add(res_list, n_list)
  return res_list
  
if __name__ == '__main__':
  run()
0