結果

問題 No.43 野球の試合
ユーザー mkawa2mkawa2
提出日時 2020-01-02 22:49:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 1,151 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 8,384 KB
最終ジャッジ日時 2023-08-14 18:42:44
合計ジャッジ時間 1,155 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,224 KB
testcase_01 AC 16 ms
8,212 KB
testcase_02 AC 16 ms
8,372 KB
testcase_03 AC 17 ms
8,380 KB
testcase_04 AC 16 ms
8,148 KB
testcase_05 AC 16 ms
8,384 KB
testcase_06 AC 17 ms
8,228 KB
testcase_07 AC 149 ms
8,376 KB
testcase_08 AC 16 ms
8,320 KB
testcase_09 AC 16 ms
8,344 KB
testcase_10 AC 16 ms
8,316 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