結果

問題 No.43 野球の試合
ユーザー roarisroaris
提出日時 2019-08-02 17:19:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 838 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 10,988 KB
実行使用メモリ 7,920 KB
最終ジャッジ日時 2023-09-18 18:18:19
合計ジャッジ時間 927 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,808 KB
testcase_01 AC 15 ms
7,884 KB
testcase_02 AC 16 ms
7,920 KB
testcase_03 AC 16 ms
7,824 KB
testcase_04 AC 16 ms
7,800 KB
testcase_05 AC 16 ms
7,884 KB
testcase_06 AC 16 ms
7,788 KB
testcase_07 AC 21 ms
7,888 KB
testcase_08 AC 15 ms
7,776 KB
testcase_09 AC 15 ms
7,916 KB
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

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:
            if i == 0:
                win_num[i] += 1
            else:
                unmatch.append((i, j))
    
l = len(unmatch)
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