結果

問題 No.43 野球の試合
ユーザー kutsutama
提出日時 2018-03-18 01:15:33
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 860 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-12-24 04:00:23
合計ジャッジ時間 1,053 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 6 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(s, i, j):
    res = 6
    if j == len(s):
        i += 1
        j = i + 1
    if i < len(s) - 1:
        if s[i][j] == '-':
            s[i][j] = 'x'
            s[j][i] = 'o'
            res = min(res, solve(s, i, j + 1))
            s[i][j] = 'o'
            s[j][i] = 'x'
            res = min(res, solve(s, i, j + 1))
            s[i][j] = '-'
            s[j][i] = '-'
        else:
            res = min(res, solve(s, i, j + 1))
    else:
        c = []
        for si in s:
            c.append(si.count('o'))
        cs = list(set(c))
        cs.sort(reverse=True)
        res = cs.index(c[0]) + 1
    return res

n = int(input())
s = []
for i in range(n):
    s.append(list(input()))
for j in range(n):
    if s[0][j] == '-':
        s[0][j] = 'o'
        s[j][0] = 'x'

res = solve(s, 1, 2)
print(res)
0