結果
| 問題 | No.43 野球の試合 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-02-12 11:13:33 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 427 ms / 5,000 ms | 
| コード長 | 494 bytes | 
| コンパイル時間 | 80 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 10,752 KB | 
| 最終ジャッジ日時 | 2024-06-28 13:13:23 | 
| 合計ジャッジ時間 | 1,406 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 7 | 
ソースコード
#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)
            
            
            
        