結果

問題 No.43 野球の試合
コンテスト
ユーザー G
提出日時 2026-04-20 15:30:58
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 1,481 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 336 ms
コンパイル使用メモリ 20,784 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2026-04-20 15:31:03
合計ジャッジ時間 2,204 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 1 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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] = "-"

                return best_rank

    print(calculate_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 calculate_rank(match_result_table, team_count)


def calculate_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()
0