class TravelingSalesman: def __init__(self, N, INF=float("inf"), directed=False, decrement=True): self.N=N self.directed=directed self.idx=decrement self.INF=INF self.cost = [[INF]*N for _ in range(N)] def add_edge(self,u,v,cost): u,v = u-self.idx, v-self.idx self.cost[u][v] = cost if self.directed==False: self.cost[v][u] = cost def shortest(self,start=None): N,INF=self.N,self.INF if start==None: start=self.idx start=start-self.idx dp = [[INF]*N for _ in range((1<dp[bit][u]+self.cost[u][v] and dp[bit][u]!=INF: dp[bit|(1<dp[bit][u]+self.cost[u][v] and dp[bit][u]!=INF: dp[bit|(1<