import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(2*10**5+10) write = lambda x: sys.stdout.write(x+"\n") debug = lambda x: sys.stderr.write(x+"\n") writef = lambda x: print("{:.12f}".format(x)) class UF: # unionfind def __init__(self, n): self.n = n self.parent = list(range(n)) self.size = [1] * n def check(self): return [self.root(i) for i in range(self.n)] def root(self, i): inter = set() while self.parent[i]!=i: inter.add(i) i = self.parent[i] r = i for i in inter: self.parent[i] = r return r def connect(self, i, j): # 繋いだかどうかを返す ri = self.root(i) rj = self.root(j) if ri==rj: return False if self.size[ri]0 and len(set([uf.root(i) for i in range(n)]))==1 from heapq import heappop as hpp, heappush as hp def t2i(*vs): n = len(vs) val = 1 nvs = [1] for v in vs[::-1]: val *= v nvs.append(val) vs = tuple(nvs[::-1]) def to(*args): return sum((v1*v2 for v1,v2 in zip(vs, args))) def frm(val): res = [] for v in vs: tmp, val = divmod(val, v) res.append(tmp) return res return to,frm def t2i(*vs): n = len(vs)+1 nvs = [1] val = 1 for v in vs[::-1]: val *= v nvs.append(val) vs = nvs[::-1] tos = "def to(%s):\n" % (",".join([f"v{i}" for i in range(n)])) tos += " val = 0\n" for i,v in enumerate(vs): tos += f" val += {v} * v{i}\n" tos += " return val" frms = f"def frm(val):\n" for i in range(n-1): frms += f" v{i},val = divmod(val, {vs[i]})\n" frms += " return %s" % ((", ".join([f"v{i}" for i in range(n-1)]) + ", val")) return tos, frms tos, frms = t2i(n,2) exec(tos) exec(frms) # to,frm = t2i(n,2) inf = 2*s + 10 vals = [[inf]*n for _ in range(2)] vals[0][n-1] = 0 q = [to(0, n-1, 0)] while q: d,u,x = frm(hpp(q)) if vals[x][u]nd: vals[nx][v] = nd hp(q, to(nd, v, nx)) ans = vals[1] write("\n".join(map(str, ans[:n-1])))