使用字符串哈希判断相等。用线段树维护操作。
因为数对 $P$ 取模,且每次只加一,因此取模的次数不超过 $n\cdot (1+q/P)$。题目中 $P=65536$,因此暴力取模就可以通过。
另一个方法是注意到两个数列相等等价于第一个数相等且差分数列相等。用树状数组维护差分数列及哈希即可。
时间复杂度 $O(n+q\log n)$。
As we are currently experiencing an overwhelming number of web requests for fetching user submissions, we have temporarily disabled the full submissions list. You must now be logged in to view submissions.
Type: Editorial
Status: Open
Posted by: jiangly
Posted at: 2025-12-13 00:20:57
Last updated: 2025-12-13 00:21:00
使用字符串哈希判断相等。用线段树维护操作。
因为数对 $P$ 取模,且每次只加一,因此取模的次数不超过 $n\cdot (1+q/P)$。题目中 $P=65536$,因此暴力取模就可以通过。
另一个方法是注意到两个数列相等等价于第一个数相等且差分数列相等。用树状数组维护差分数列及哈希即可。
时间复杂度 $O(n+q\log n)$。