結果
| 問題 | No.43 野球の試合 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-20 15:36:57 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,501 bytes |
| 記録 | |
| コンパイル時間 | 512 ms |
| コンパイル使用メモリ | 20,696 KB |
| 実行使用メモリ | 15,484 KB |
| 最終ジャッジ日時 | 2026-04-20 15:37:02 |
| 合計ジャッジ時間 | 2,412 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 3 WA * 4 |
ソースコード
def main():
team_count = int(input())
match_result_table = [list(input()) for _ in range(team_count)]
best_rank = team_count
for i in range(team_count):
for j in range(i + 1, team_count):
if match_result_table[i][j] == "-":
match_result_table[i][j], match_result_table[j][i] = "o", "x"
best_rank = min(best_rank, explore_match_outcomes(match_result_table, team_count))
match_result_table[i][j], match_result_table[j][i] = "x", "o"
best_rank = min(best_rank, explore_match_outcomes(match_result_table, team_count))
match_result_table[i][j] = match_result_table[j][i] = "-"
print(best_rank)
return
print(state_to_rank(match_result_table, team_count))
def explore_match_outcomes(match_result_table, team_count):
for i in range(team_count):
for j in range(i + 1, team_count):
if match_result_table[i][j] == "-":
return team_count
return state_to_rank(match_result_table, team_count)
def state_to_rank(match_result_table, team_count):
win_count = [0] * team_count
for i in range(team_count):
for j in range(team_count):
if i != j and match_result_table[i][j] == "o":
win_count[i] += 1
sorted_unique_win_counts = sorted(set(win_count), reverse=True)
return sorted_unique_win_counts.index(win_count[0]) + 1
if __name__ == "__main__":
main()