結果

問題 No.43 野球の試合
ユーザー kichirb3kichirb3
提出日時 2018-03-31 15:47:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,793 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 8,404 KB
最終ジャッジ日時 2023-09-08 08:16:27
合計ジャッジ時間 1,130 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,296 KB
testcase_01 AC 16 ms
8,300 KB
testcase_02 AC 16 ms
8,248 KB
testcase_03 AC 15 ms
8,200 KB
testcase_04 AC 16 ms
8,292 KB
testcase_05 AC 15 ms
8,204 KB
testcase_06 AC 16 ms
8,404 KB
testcase_07 AC 16 ms
8,216 KB
testcase_08 AC 16 ms
8,304 KB
testcase_09 AC 16 ms
8,212 KB
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
"""
No.43 野球の試合
https://yukicoder.me/problems/no/43

"""
import sys
from sys import stdin
input = stdin.readline


def update_status(N, result):
    # 残り試合があるチーム情報を[現時点での勝ち星数, チーム番号]でリスト化
    res = []
    for i, row in enumerate(result[1:], start=1):
        if '-' in row:
            win = row.count('o')
            res.append([win, i])
    return res


def solve(N, result):
    # K君のチームに未消化の試合があれば全勝したことにする
    for x in range(N):
        if result[0][x] == '-':
            result[0][x] = 'o'
            result[x][0] = 'x'

    # 残り試合があるチームがあれば、残り試合を消化する
    remainings = update_status(N, result)
    while remainings:
        remainings.sort()
        _, t = remainings[-1]   #  現時点で一番勝ち星数が多いチームをピックアップして
        x = result[t].index('-')
        result[t][x] = 'x'      #  1試合分負けたことにする
        result[x][t] = 'o'      #  (対戦相手は勝ったことにする)
        remainings = update_status(N, result)

    # 他チームの勝ち星数をチェック
    winnings = []
    for r in result[1:]:
        w = r.count('o')
        if w not in winnings:
            winnings.append(w)
    # 自分のチームの勝ち星数と比較して順位を決定する
    my_winning = result[0].count('o')
    ans = 1
    for w in winnings:
        if w > my_winning:
            ans += 1
    return ans


def main(args):
    N = int(input())
    result = []
    for _ in range(N):
        result.append(list(input().strip()))

    ans = solve(N, result)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
0