結果

問題 No.43 野球の試合
ユーザー roarisroaris
提出日時 2019-08-02 17:26:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 236 ms / 5,000 ms
コード長 936 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 8,100 KB
最終ジャッジ日時 2023-09-18 18:18:46
合計ジャッジ時間 1,102 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,892 KB
testcase_01 AC 15 ms
8,100 KB
testcase_02 AC 16 ms
7,816 KB
testcase_03 AC 16 ms
7,836 KB
testcase_04 AC 16 ms
7,788 KB
testcase_05 AC 16 ms
7,816 KB
testcase_06 AC 17 ms
7,924 KB
testcase_07 AC 236 ms
7,736 KB
testcase_08 AC 16 ms
7,716 KB
testcase_09 AC 16 ms
8,080 KB
testcase_10 AC 16 ms
7,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
s = [input() for _ in range(N)]
win_num = {i: 0 for i in range(N)}
unmatch = []

for i in range(N):
    for j in range(i+1, N):
        if s[i][j] == 'o':
            win_num[i] += 1
        elif s[i][j] == 'x':
            win_num[j] += 1
        else:
            unmatch.append((i, j))

l = len(unmatch)

if l == 0:
    for i, value in enumerate(sorted(list(set(win_num.values())), reverse=True), 1):
        if win_num[0] == value:
            print(i)
            exit()
    
ans = 10 ** 18

for i in range(2 ** l):
    win_num_copy = win_num.copy()
    
    for j in range(l):
        if (i >> j) & 1:
            win_num_copy[unmatch[j][0]] += 1
        else:
            win_num_copy[unmatch[j][1]] += 1

    for i, value in enumerate(sorted(list(set(win_num_copy.values())), reverse=True), 1):
        
        if win_num_copy[0] == value:
            ans_cand = i
    
    ans = min(ans, ans_cand)

print(ans)
0