結果
| 問題 | No.43 野球の試合 | 
| コンテスト | |
| ユーザー |  mkawa2 | 
| 提出日時 | 2019-12-20 00:23:07 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 159 ms / 5,000 ms | 
| コード長 | 1,151 bytes | 
| コンパイル時間 | 154 ms | 
| コンパイル使用メモリ | 12,800 KB | 
| 実行使用メモリ | 11,008 KB | 
| 最終ジャッジ日時 | 2024-07-07 02:15:46 | 
| 合計ジャッジ時間 | 1,114 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 7 | 
ソースコード
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()
            
            
            
        