結果

問題 No.43 野球の試合
ユーザー 👑 rin204rin204
提出日時 2022-01-20 21:09:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 65,792 KB
最終ジャッジ日時 2024-05-03 07:41:47
合計ジャッジ時間 1,068 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,224 KB
testcase_01 AC 35 ms
51,968 KB
testcase_02 AC 33 ms
51,968 KB
testcase_03 AC 32 ms
52,224 KB
testcase_04 AC 33 ms
51,840 KB
testcase_05 AC 34 ms
52,224 KB
testcase_06 AC 42 ms
60,800 KB
testcase_07 AC 49 ms
65,792 KB
testcase_08 AC 32 ms
51,968 KB
testcase_09 AC 33 ms
52,224 KB
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = [list(input()) for _ in range(n)]
win = 0
for j in range(1, n):
    if S[0][j] == "-":
        S[0][j] = "o"
        S[j][0] = "x"
    if S[0][j] == "o":
        win += 1

lst = []    
for i in range(1, n):
    for j in range(i + 1, n):
        if S[i][j] == "-":
            lst.append((i, j))
ans = n
l = len(lst)
for bit in range(1 << l):
    for i in range(l):
        if bit >> i & 1:
            S[lst[i][0]][lst[i][1]] = "o"
            S[lst[i][1]][lst[i][0]] = "x"
        else:
            S[lst[i][0]][lst[i][1]] = "x"
            S[lst[i][1]][lst[i][0]] = "o"
            
    se = {win}
    for i in range(1, n):
        tot = 0
        for j in range(n):
            if S[i][j] == "o":
                tot += 1
        se.add(tot)
    ls = sorted(se, reverse = True)
    ans = min(ans, ls.index(win) + 1)
print(ans)
    
    
    
0