結果
問題 | No.43 野球の試合 |
ユーザー |
![]() |
提出日時 | 2025-04-15 23:24:27 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,447 bytes |
コンパイル時間 | 215 ms |
コンパイル使用メモリ | 82,340 KB |
実行使用メモリ | 62,464 KB |
最終ジャッジ日時 | 2025-04-15 23:25:50 |
合計ジャッジ時間 | 1,060 ms |
ジャッジサーバーID (参考情報) |
judge2 / 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 remaining = [] for i in range(n): for j in range(i + 1, n): if s[i][j] == '-': remaining.append((i, j)) # Process remaining matches involving team 0 new_remaining = [] for (i, j) in remaining: if i == 0 or j == 0: current_wins[0] += 1 else: new_remaining.append((i, j)) remaining = new_remaining min_rank = n # Initialize with worst possible rank m = len(remaining) for mask in range(0, 1 << m): wins = current_wins.copy() for k in range(m): i, j = remaining[k] if (mask >> k) & 1: wins[j] += 1 else: wins[i] += 1 sorted_wins = sorted(wins, reverse=True) target = wins[0] rank = 1 prev = sorted_wins[0] current_rank = 1 found = False for idx, w in enumerate(sorted_wins): if w == target: if idx != 0 and w == sorted_wins[idx - 1]: pass else: current_rank = rank found = True break if w != prev: current_rank = rank prev = w rank += 1 if not found: current_rank = rank if current_rank < min_rank: min_rank = current_rank print(min_rank)