Rosetta Problems

ICPC 2021 miền Bắc - K: Lexigraphical Matrix

https://oj.vnoi.info/problem/icpc21_mb_k