結果

問題 No.43 野球の試合
ユーザー nebukuro09
提出日時 2016-10-27 11:41:25
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-24 04:02:59
合計ジャッジ時間 686 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 2 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product

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

for i in xrange(N):
    if league[0][i] == '-':
        league[0][i] = 'o'
        league[i][0] = 'x'

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 rank

print ans
0