結果

問題 No.43 野球の試合
ユーザー szkhtsszkhts
提出日時 2021-10-16 08:40:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 461 ms / 5,000 ms
コード長 888 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 11,796 KB
実行使用メモリ 10,188 KB
最終ジャッジ日時 2023-10-17 22:03:53
合計ジャッジ時間 1,689 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,188 KB
testcase_01 AC 32 ms
10,188 KB
testcase_02 AC 32 ms
10,188 KB
testcase_03 AC 33 ms
10,188 KB
testcase_04 AC 32 ms
10,188 KB
testcase_05 AC 32 ms
10,188 KB
testcase_06 AC 34 ms
10,188 KB
testcase_07 AC 461 ms
10,188 KB
testcase_08 AC 32 ms
10,188 KB
testcase_09 AC 32 ms
10,188 KB
testcase_10 AC 32 ms
10,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy

N = int(input())
s = [input() for _ in range(N)]

a = []
b = []
win = [0] * N
for i in range(N):
    for j in range(i):
        if s[i][j] == '-':
            a.append(i)
            b.append(j)
        elif s[i][j] == 'o':
            win[i] += 1
        else:
            win[j] += 1

ans = N
for i in range(1 << len(a)):
    wintemp = copy.deepcopy(win)
    for j in range(len(a)):
        if (i >> j) % 2 == 0:
            wintemp[a[j]] += 1
        else:
            wintemp[b[j]] += 1

    for j in range(N):
        wintemp[j] = wintemp[j] * N + j

    wintemp.sort()
    wintemp = wintemp[::-1]

    place = 0
    prepoint = -1
    for j in range(N):
        winnum = wintemp[j] // N
        team = wintemp[j] % N
        if prepoint != winnum:
            prepoint = winnum
            place += 1

        if team == 0:
            ans = min(place, ans)

print(ans)
0