結果
問題 | No.43 野球の試合 |
ユーザー |
![]() |
提出日時 | 2025-03-31 17:26:25 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,393 bytes |
コンパイル時間 | 216 ms |
コンパイル使用メモリ | 82,836 KB |
実行使用メモリ | 63,560 KB |
最終ジャッジ日時 | 2025-03-31 17:27:45 |
合計ジャッジ時間 | 1,238 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 # Calculate team 0's maximum possible wins by winning all remaining matches remaining_0 = 0 for j in range(n): if j == 0: continue if s[0][j] == '-': remaining_0 += 1 max_wins0 = current_wins[0] + remaining_0 # Collect remaining matches between other teams (i, j where i < j and neither is 0) remaining_matches = [] for i in range(n): for j in range(i + 1, n): if i == 0 or j == 0: continue if s[i][j] == '-': remaining_matches.append((i, j)) m = len(remaining_matches) min_rank = float('inf') # Generate all possible outcomes for the remaining matches for mask in range(1 << m): wins = current_wins.copy() wins[0] = max_wins0 # Team 0's wins are fixed # Apply the current mask to determine outcomes of remaining matches for k in range(m): i, j = remaining_matches[k] if (mask >> k) & 1: wins[j] += 1 # j wins else: wins[i] += 1 # i wins # Calculate rank for team 0 sorted_wins = sorted(wins, reverse=True) rank = sorted_wins.index(wins[0]) + 1 if rank < min_rank: min_rank = rank print(min_rank)