The PDF version of this problem can be downloaded here.
Migrated from old NTUJ.
JAG Practice Contest for ACM-ICPC Asia Regional 2017, AtCoder, 2017–09–24