結果
問題 | No.43 野球の試合 |
ユーザー |
![]() |
提出日時 | 2022-08-03 00:44:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 109 ms / 5,000 ms |
コード長 | 1,109 bytes |
コンパイル時間 | 720 ms |
コンパイル使用メモリ | 82,412 KB |
実行使用メモリ | 76,800 KB |
最終ジャッジ日時 | 2024-07-23 18:56:52 |
合計ジャッジ時間 | 1,542 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 |
ソースコード
N = int(input())S = [list(input()) for _ in range(N)]l = [i for i in range(N)]from itertools import combinationsl = combinations(l,2)l = list(l)all = N*(N-1)//2now = Nfor s in range(2**all):d = [0 for _ in range(N)]pi = Truefor i in range(all):p,q = l[i]w = 0if S[p][q] == "-":if s>>i & 1:w = 0else:w = 1elif (S[p][q] == "o" and s>>i & 1) or (S[p][q] == "x" and s>>i & 1 == 0):if S[p][q] == "o":w = 0else:w = 1else:pi = Falsebreakif w == 0:d[p] += 1else:d[q] += 1if not pi:continuell = []for i in range(len(d)):ll.append((d[i],i))ll.sort(key=lambda x:(-x[0],x[1]))a = ll[0][0]b = 1if ll[0][1] == 0:now = 1breakfor i in range(1,N):if ll[i-1][0] != ll[i][0]:b += 1if ll[i][1] == 0:now = min(now,b)breakprint(now)