結果

問題 No.43 野球の試合
ユーザー convexineqconvexineq
提出日時 2020-12-03 20:23:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 612 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 78,804 KB
最終ジャッジ日時 2023-10-12 06:26:31
合計ジャッジ時間 1,796 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
70,996 KB
testcase_01 AC 70 ms
71,352 KB
testcase_02 AC 70 ms
71,492 KB
testcase_03 AC 71 ms
71,392 KB
testcase_04 AC 71 ms
71,524 KB
testcase_05 AC 70 ms
71,404 KB
testcase_06 AC 81 ms
75,920 KB
testcase_07 AC 127 ms
78,804 KB
testcase_08 AC 70 ms
71,356 KB
testcase_09 AC 70 ms
71,516 KB
testcase_10 AC 71 ms
71,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
b = [input() for _ in range(n)]

def dfs(i,j):
    global ans
    if i==n-1:
        sr = sorted(set(r),reverse=True)
        ans = min(ans,sr.index(r[0])+1)
        return
    if i >= j: return dfs(i,j+1)

    ni,nj = i,j+1
    if nj >= n:
        nj = 0
        ni = i+1
    
    if b[i][j] == "o":
        r[i] += 1
        dfs(ni,nj)
        r[i] -= 1
    elif b[i][j] == "x":
        r[j] += 1
        dfs(ni,nj)
        r[j] -= 1
    else:
        r[i] += 1
        dfs(ni,nj)
        r[i] -= 1
        r[j] += 1
        dfs(ni,nj)
        r[j] -= 1


ans = 6
r = [0]*n
dfs(0,0)
print(ans)
0