Takahashi is Nervous

2 secs 1024 MB
magurofly's icon magurofly

解説

頂点を LL 倍してダイクストラ法を使うことで答えを O((M+N)Llog(NL))O((M + N)L \log(NL)) で求めることができます。