結果

問題 No.43 野球の試合
ユーザー 👑 rin204rin204
提出日時 2022-01-20 21:10:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 807 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 77,156 KB
最終ジャッジ日時 2023-08-15 21:09:45
合計ジャッジ時間 2,067 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,412 KB
testcase_01 AC 76 ms
71,464 KB
testcase_02 AC 76 ms
71,264 KB
testcase_03 AC 79 ms
71,300 KB
testcase_04 AC 75 ms
71,500 KB
testcase_05 AC 75 ms
71,308 KB
testcase_06 AC 92 ms
76,812 KB
testcase_07 AC 138 ms
77,156 KB
testcase_08 AC 76 ms
71,504 KB
testcase_09 AC 76 ms
71,388 KB
testcase_10 AC 77 ms
71,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = [list(input()) for _ in range(n)]
lst = []    
for i in range(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"
    
    win = 0
    for j in range(1, n):
        if S[0][j] == "o":
            win += 1
    
    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