結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
kichirb3
|
| 提出日時 | 2018-03-31 15:47:32 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,793 bytes |
| コンパイル時間 | 95 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-06-26 01:36:00 |
| 合計ジャッジ時間 | 1,024 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 6 WA * 1 |
ソースコード
# -*- 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:])
kichirb3