https://www.luogu.com.cn/paste/3f2wr0sj
Shunpower 大神之前出了一道题有类似的判定,所以大神给了我代码我尝试写了个 SPJ。
本地简单测了样例,应该是对的。