結果

問題 No.43 野球の試合
ユーザー pluto77pluto77
提出日時 2022-02-12 11:13:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 383 ms / 5,000 ms
コード長 494 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 10,800 KB
実行使用メモリ 8,292 KB
最終ジャッジ日時 2023-09-10 22:13:21
合計ジャッジ時間 1,542 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,292 KB
testcase_01 AC 17 ms
8,164 KB
testcase_02 AC 17 ms
8,252 KB
testcase_03 AC 17 ms
8,144 KB
testcase_04 AC 17 ms
8,280 KB
testcase_05 AC 17 ms
8,160 KB
testcase_06 AC 18 ms
8,156 KB
testcase_07 AC 383 ms
8,224 KB
testcase_08 AC 16 ms
8,148 KB
testcase_09 AC 16 ms
8,248 KB
testcase_10 AC 16 ms
8,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki43
from itertools import product

n=int(input())
s=[]
r=[]
for i in range(n):
 s.append(list(input()))
 for j in range(i+1,n):
  if s[-1][j]=='-':
   r.append((i,j))
res=n
for t in product([0,1],repeat=len(r)):
 for k,(i,j) in enumerate(r):
  if t[k]==1:
   s[i][j],s[j][i]='o','x'
  else:
   s[i][j],s[j][i]='x','o'
 x=set()
 for i in range(n):
  x.add(s[i].count('o'))
 x=sorted(x,reverse=True)

 res=min(res,x.index(s[0].count('o'))+1)

 for i,j in r:
  s[i][j]=s[j][i]='-'

print(res)
0