結果

問題 No.43 野球の試合
ユーザー nebukuro09nebukuro09
提出日時 2016-10-27 11:43:19
言語 Python2
(2.7.18)
結果
AC  
実行時間 300 ms / 5,000 ms
コード長 710 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 6,732 KB
実行使用メモリ 6,288 KB
最終ジャッジ日時 2023-08-15 20:20:50
合計ジャッジ時間 1,037 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,148 KB
testcase_01 AC 10 ms
6,172 KB
testcase_02 AC 10 ms
6,112 KB
testcase_03 AC 10 ms
6,288 KB
testcase_04 AC 11 ms
6,148 KB
testcase_05 AC 10 ms
6,288 KB
testcase_06 AC 12 ms
6,288 KB
testcase_07 AC 300 ms
6,280 KB
testcase_08 AC 10 ms
6,152 KB
testcase_09 AC 9 ms
6,248 KB
testcase_10 AC 9 ms
6,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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