結果

問題 No.43 野球の試合
コンテスト
ユーザー nebukuro09
提出日時 2016-10-27 11:43:19
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 244 ms / 5,000 ms
コード長 710 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 142 ms
コンパイル使用メモリ 77,600 KB
最終ジャッジ日時 2025-12-03 22:25:21
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from itertools import product

N = input()
league = [list(raw_input()) for _ in xrange(N)]

unfixed = []
for i in xrange(N):
    for j in xrange(i+1, N):
        if league[i][j] == '-':
            unfixed.append((i, j))

if len(unfixed) == 0:
    rank = sorted(set(map(lambda x:x.count('o'), league)), reverse=True)
    print rank.index(league[0].count('o'))+1
    exit()
ans = N+1
for ox in product('ox', repeat=len(unfixed)):
    for k in xrange(len(unfixed)):
        i, j = unfixed[k]
        league[i][j] = ox[k]
        league[j][i] = 'o' if ox[k] == 'x' else 'x'
    rank = sorted(set(map(lambda x:x.count('o'), league)), reverse=True)
    ans = min(ans, rank.index(league[0].count('o'))+1)

print ans
0