Rosetta Problems

JOI国のお散歩事情 (Walking in JOI Kingdom)

https://atcoder.jp/contests/joi2016yo/tasks/joi2016yo_d