class order:
"""
@param score: When the j-th driver gets the i-th order, we can get score[i][j] points.
@return: return an array that means the array[i]-th driver gets the i-th order.
"""
def orderAllocation(self, score):
n = len(score)
if n == 0:
return []
if n == 1:
return [0]
visit = [0] * n
res = [0] * n
val = -1
def dfs(i, path, total):
if i == n:
nonlocal val
if total > val:
val = total
res[:] = path[:]
return
for j in range(n):
if visit[j] == 1:
continue
visit[j] = 1
path.append(j)
dfs(i + 1, path, total + score[i][j])
path.pop()
visit[j] = 0
dfs(0, [], 0)
return res
score=[[1,2,4],[7,11,16],[37,29,22]]
model=order()
print(model.orderAllocation(score))