https://www.luogu.org/blog/NoobYlh/solution-p1470