結果
問題 | No.43 野球の試合 |
ユーザー |
![]() |
提出日時 | 2025-04-15 23:26:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,134 bytes |
コンパイル時間 | 311 ms |
コンパイル使用メモリ | 82,272 KB |
実行使用メモリ | 75,692 KB |
最終ジャッジ日時 | 2025-04-15 23:27:28 |
合計ジャッジ時間 | 1,161 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 WA * 2 |
ソースコード
n = int(input()) s = [input().strip().replace(' ', '') for _ in range(n)] initial_wins = [0] * n for i in range(n): for j in range(n): if i == j: continue if s[i][j] == 'o': initial_wins[i] += 1 remaining = [] for i in range(n): for j in range(i + 1, n): if s[i][j] == '-': remaining.append((i, j)) m = len(remaining) min_rank = float('inf') for mask in range(0, 1 << m): temp_wins = initial_wins.copy() for k in range(m): i, j = remaining[k] if (mask >> k) & 1: temp_wins[j] += 1 else: temp_wins[i] += 1 sorted_wins = sorted(temp_wins, reverse=True) current_rank = 1 pos = 0 found = False while pos < n and not found: current_win = sorted_wins[pos] count = 0 while pos + count < n and sorted_wins[pos + count] == current_win: count += 1 if temp_wins[0] == current_win: if current_rank < min_rank: min_rank = current_rank found = True current_rank += count pos += count print(min_rank)