rt,借鉴了@Chenyufeng040525 的思路,此题存在 O(n+m) 解法。
另外有没有懂的知道我能不能把那两个题都合并到本题来?
https://www.luogu.com.cn/problem/U502888