結果

問題 No.43 野球の試合
ユーザー zombietanzombietan
提出日時 2016-05-10 05:15:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 639 ms / 5,000 ms
コード長 911 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 17,664 KB
最終ジャッジ日時 2024-04-15 15:01:58
合計ジャッジ時間 1,614 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 33 ms
10,880 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 35 ms
11,008 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 31 ms
11,008 KB
testcase_06 AC 35 ms
10,880 KB
testcase_07 AC 639 ms
17,664 KB
testcase_08 AC 32 ms
11,008 KB
testcase_09 AC 32 ms
10,880 KB
testcase_10 AC 33 ms
10,880 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')
pat = []
for p in itertools.product(WL, repeat=rg):
    pat.append(list(p))

CS = [x[:] for x in S]
rup = []
for g in pat:
    wn = []
    for idx, ss in enumerate(S):
        for idxx, sss in enumerate(ss):
            if CS[idx][idxx] == '-':
                wl = g.pop()
                if wl == 'o':
                    CS[idx][idxx] = 'o'
                    CS[idxx][idx] = 'x'
                else:
                    CS[idx][idxx] = 'x'
                    CS[idxx][idx] = '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)
    CS = [x[:] for x in S]

print(min(rup))
    
0