結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-06 08:06:10 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 5,000 ms |
| コード長 | 882 bytes |
| コンパイル時間 | 209 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-11-06 11:00:20 |
| 合計ジャッジ時間 | 1,184 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
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())
matrix = [input() for i in range(n)]
win_count = []
yet_coor = []
for i, row in enumerate(matrix):
win = 0
for j, cell in enumerate(row):
if cell == 'o':
win += 1
if i < j:
if cell == '-':
yet_coor.append([i, j])
win_count.append(win)
w_list = [0] * n
print(dfs(0))