結果

問題 No.43 野球の試合
ユーザー zombietanzombietan
提出日時 2016-05-10 07:45:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 524 ms / 5,000 ms
コード長 807 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-15 15:02:07
合計ジャッジ時間 1,530 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,624 KB
testcase_01 AC 33 ms
10,752 KB
testcase_02 AC 34 ms
10,624 KB
testcase_03 AC 33 ms
10,624 KB
testcase_04 AC 32 ms
10,752 KB
testcase_05 AC 31 ms
10,624 KB
testcase_06 AC 35 ms
10,752 KB
testcase_07 AC 524 ms
11,136 KB
testcase_08 AC 32 ms
10,624 KB
testcase_09 AC 31 ms
10,624 KB
testcase_10 AC 32 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
N = int(input())
S = [list(input()) for _ in range(N)]

count = 0
for s in S:
    for m in s:
        if m == '-':
            count += 1
    
rg = count//2
WL = ('o','x')
rup = []

for pat in itertools.product(WL, repeat=rg):
    p = list(pat)
    CS = [x[:] for x in S]
    wn = []
    for j in range(N):
        for k in range(N):
            if CS[j][k] == '-':
                wl = p.pop()
                if wl == 'o':
                    CS[j][k] = 'o'
                    CS[k][j] = 'x'
                else:
                    CS[j][k] = 'x'
                    CS[k][j] = 'o'
    for cs in CS:
        w = cs.count('o')
        wn.append(w)
    tw = wn[0]
    swn = list(set(wn))
    wn = sorted(swn, reverse=True)
    rank = wn.index(tw) + 1
    rup.append(rank)
print(min(rup))
0