結果

問題 No.43 野球の試合
ユーザー mkawa2mkawa2
提出日時 2019-12-20 00:23:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 1,151 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 11,020 KB
実行使用メモリ 8,348 KB
最終ジャッジ日時 2023-09-21 07:50:59
合計ジャッジ時間 1,309 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,220 KB
testcase_01 AC 16 ms
8,220 KB
testcase_02 AC 16 ms
8,348 KB
testcase_03 AC 16 ms
8,304 KB
testcase_04 AC 16 ms
8,244 KB
testcase_05 AC 16 ms
8,316 KB
testcase_06 AC 17 ms
8,196 KB
testcase_07 AC 149 ms
8,224 KB
testcase_08 AC 16 ms
8,156 KB
testcase_09 AC 16 ms
8,300 KB
testcase_10 AC 16 ms
8,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    def dfs(i=0, j=0):
        res = 10
        for ni in range(i, n):
            for nj in range(ni + 1, n):
                if ni == i and nj <= j: continue
                if t[ni][nj] == -1:
                    t[ni][nj] = 1
                    t[nj][ni] = 0
                    res = min(dfs(ni, nj), res)
                    t[ni][nj] = 0
                    t[nj][ni] = 1
                    res = min(dfs(ni, nj), res)
                    t[ni][nj] = -1
                    t[nj][ni] = -1
                    return res
        #p2D(t)
        #print()
        score = set(sum(tk) for tk in t)
        s0 = sum(t[0])
        for i, s in enumerate(sorted(score, reverse=True)):
            if s == s0: return i + 1

    n = int(input())
    t = [[(c == "o") * 1 - (c == "-") * 1 for c in input()] for _ in range(n)]
    print(dfs())

main()
0