codeforces 766D Mahmoud and a Dictionary(带权并查集+map查询)

NoSuchKey