Rosetta Problems

IOI列車で行こう

https://hoj.hamako-ths.ed.jp/onlinejudge/problems/222