codeforces #541 D. Gourmet choice(拓扑+并查集)

NoSuchKey