import sequtils template times*(n:int,body) = (for _ in 0.." .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord proc topologicalSort(E:seq[seq[int]]) : seq[int] = # E : [n->[m1,m2,m3], ... ]の隣接リスト を ソート var visited = newSeq[bool](E.len) var answer = newSeq[int]() proc visit(src:int) = if visited[src] : return visited[src] = true for dst in E[src]: visit(dst) answer &= src # 葉から順に追加される for src in 0..