結果

問題 No.43 野球の試合
ユーザー convexineqconvexineq
提出日時 2020-12-03 20:07:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 651 bytes
コンパイル時間 951 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 78,556 KB
最終ジャッジ日時 2023-10-12 06:06:13
合計ジャッジ時間 2,112 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,580 KB
testcase_01 AC 78 ms
71,320 KB
testcase_02 AC 77 ms
71,328 KB
testcase_03 AC 79 ms
71,376 KB
testcase_04 WA -
testcase_05 AC 79 ms
71,440 KB
testcase_06 AC 89 ms
75,880 KB
testcase_07 AC 137 ms
78,556 KB
testcase_08 AC 77 ms
71,164 KB
testcase_09 AC 79 ms
71,128 KB
testcase_10 AC 78 ms
71,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
b = [input() for _ in range(n)]
#s = ["x" if bi=="x" else "o" for bi in b[0]]
#b[0] = "".join(s)
#print(b)

ans = 6
r = [0]*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)
    elif b[i][j] == "x":
        r[j] += 1
        dfs(ni,nj)
    else:
        r[i] += 1
        dfs(ni,nj)
        r[i] -= 1
        r[j] += 1
        dfs(ni,nj)
        r[j] -= 1

dfs(0,0)
print(ans)
0