結果

問題 No.43 野球の試合
ユーザー nebukuro09nebukuro09
提出日時 2016-10-27 11:37:59
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 760 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-03 06:20:04
合計ジャッジ時間 779 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 = map(lambda x:x.count('o'), league)
    print sum([r > rank[0] for r in rank])+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 = map(lambda x:x.count('o'), league)
    ans = min(ans, sum([r > rank[0] for r in rank])+1)


print ans
0