結果

問題 No.43 野球の試合
ユーザー matsu7874matsu7874
提出日時 2016-01-01 08:23:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 594 ms / 5,000 ms
コード長 742 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 10,148 KB
最終ジャッジ日時 2023-10-19 13:00:53
合計ジャッジ時間 1,609 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,144 KB
testcase_01 AC 29 ms
10,144 KB
testcase_02 AC 29 ms
10,144 KB
testcase_03 AC 28 ms
10,144 KB
testcase_04 AC 29 ms
10,144 KB
testcase_05 AC 28 ms
10,144 KB
testcase_06 AC 32 ms
10,148 KB
testcase_07 AC 594 ms
10,148 KB
testcase_08 AC 28 ms
10,144 KB
testcase_09 AC 27 ms
10,144 KB
testcase_10 AC 28 ms
10,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
N = int(input())
S = [[c for c in input()] for i in range(N)]

best_pos = N
undefined = []
for i in range(0,N):
    for j in range(i+1,N):
        if S[i][j] == '-':
            undefined.append((i,j))
for d in itertools.product('ox',repeat=len(undefined)):
    win = [0 for i in range(N)]
    for i in range(N):
        for j in range(i+1,N):
            if S[i][j] == 'o':
                win[i] += 1
            elif S[i][j] == 'x':
                win[j] += 1
            elif S[i][j] == '-':
                if d[undefined.index((i,j))] == 'o':
                    win[i]+=1
                else:
                    win[j] += 1
    best_pos = min(best_pos, sorted(list(set(win)))[::-1].index(win[0])+1)
print(best_pos)
0