結果
問題 | No.43 野球の試合 |
ユーザー |
![]() |
提出日時 | 2025-03-20 20:25:03 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,146 bytes |
コンパイル時間 | 173 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 64,704 KB |
最終ジャッジ日時 | 2025-03-20 20:26:31 |
合計ジャッジ時間 | 1,221 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 WA * 2 |
ソースコード
n = int(input()) s = [input().strip() for _ in range(n)] current_wins = [0] * n for i in range(n): for j in range(n): if i == j: continue if s[i][j] == 'o': current_wins[i] += 1 unplayed_0_matches = 0 for j in range(1, n): if s[0][j] == '-': unplayed_0_matches += 1 max_wins = current_wins[0] + unplayed_0_matches matches = [] for i in range(1, n): for j in range(i + 1, n): if s[i][j] == '-': matches.append((i, j)) m = len(matches) min_rank = float('inf') from itertools import product for bits in product([0, 1], repeat=m): added = [0] * n for k in range(m): i, j = matches[k] if bits[k]: added[i] += 1 else: added[j] += 1 wins = [0] * n wins[0] = max_wins for team in range(1, n): wins[team] = current_wins[team] + added[team] sorted_wins = sorted(wins, reverse=True) rank = None for idx in range(len(sorted_wins)): if sorted_wins[idx] == max_wins: rank = idx + 1 break if rank < min_rank: min_rank = rank print(min_rank)