結果

問題 No.43 野球の試合
ユーザー yozayoza
提出日時 2014-10-20 00:58:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 1,135 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 7,896 KB
最終ジャッジ日時 2023-08-28 21:31:02
合計ジャッジ時間 977 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,752 KB
testcase_01 AC 15 ms
7,788 KB
testcase_02 AC 16 ms
7,804 KB
testcase_03 AC 16 ms
7,820 KB
testcase_04 AC 16 ms
7,740 KB
testcase_05 AC 16 ms
7,824 KB
testcase_06 AC 17 ms
7,896 KB
testcase_07 AC 73 ms
7,844 KB
testcase_08 AC 16 ms
7,836 KB
testcase_09 AC 16 ms
7,812 KB
testcase_10 AC 16 ms
7,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def dfs(depth):
    if depth == len(yet_coor):
        count = 0
        k_win = win_count[0] + w_list[0]
        pre_list = []
        for i, j in list(zip(win_count, w_list))[1:]:
            if k_win < i + j and i + j not in pre_list:
                count += 1
                pre_list.append(i + j)
        return count + 1

    r, c = yet_coor[depth]
    w_list[r] += 1
    tmp_rank = dfs(depth + 1)
    w_list[r] -= 1
    w_list[c] += 1
    tmp_rank = min(tmp_rank, dfs(depth + 1))
    w_list[c] -= 1
    return tmp_rank

n = int(input())
table = [input() for i in range(n)]

win_count = []
yet_coor = []
for i, row in enumerate(table):
    win = 0
    # print(i, row)
    for j, cell in enumerate(row):
        if cell == 'o':
            win += 1
        # if i >= j:
            # if cell == 'o':
                # win += 1
        # elif i == 0 and cell == '-':
            # win += 1
            # table[j][i] = 'x'
        if i < j:
            if cell == '-':
                yet_coor.append([i, j])
    win_count.append(win)

w_list = [0] * n
# print(yet_coor)

print(dfs(0))
0