結果

問題 No.43 野球の試合
ユーザー c-yanc-yan
提出日時 2021-03-24 22:12:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 612 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 8,284 KB
最終ジャッジ日時 2023-08-17 22:36:50
合計ジャッジ時間 1,147 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product

N = int(input())
s = [input() for _ in range(N)]


def f(p):
    t = 0
    wins = [0] * N
    for i in range(N):
        for j in range(i + 1, N):
            if s[i][j] != p[t]:
                return -1
            if p[t] == 'o':
                wins[i] += 1
            elif p[t] == 'x':
                wins[j] += 1
            t += 1
    a = wins[0]
    wins = sorted(set(wins))
    for i in range(N):
        if wins[i] != a:
            continue
        return i + 1


result = 10 ** 18
for p in product(['o', 'x'], repeat=N * (N - 1) // 2):
    result = min(result, f(p))
0