Codeforces1100E. Andrew and Taxi(二分+dfs判环+拓扑排序)

NoSuchKey