跳到正文

题解

[ABC274Ex] XOR Sum of Arrays Tutorial

MatrixGroup约 3 分钟
原文
文章信息与版本

文章信息

发布
2024年10月1日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 3 分钟
获赞
3

版本

  1. v1当前

To determine the lexicographical order of two sequences, one can firstly evaluate the length of their longest common prefix, then compare the first different element of the sequences. With binary search, one only needs to check whether two sequences are identical, then the whole problem can be easily solved.

Consider hashing. One can easily evaluate the hash value of a subarray of a sequence by precomuting all the hash values of the prefixes, provided that the hash is a polynomial hash. However, one cannot find the hash value of the bitwise exclusive or of two sequences by the hash value of these sequences.

Therefore, one may want to find some operation that is distributive on bitwise exclusive or. If there is any, one can use the operation and bitwise exclusive or to build something analogous to a polynomial hash, which means the new hash value of the bitwise exclusive or of two sequences is exactly the bitwise exclusive or of the hash value of the two sequences.

In fact, any Galois field of order 22, denoted as F2k\mathbb F_{2^k}, is exactly what is desired. Take F262\mathbb F_{2^{62}} as an example, one way to evalutate the product in F262\mathbb F_{2^{62}} is to represent numbers as polynomials whose degree is no more than 6161 and coefficients in F2\mathbb F_2, and take a prime polynomial as the modulus when computing products. One such polynomial is x62+x6+x5+x3+1x^{62}+x^6+x^5+x^3+1.

The whole time complexity is O(Nw+Qwlog⁡N)O(Nw+Qw\log N), where ww denotes the size of the field is 2w2^w. The probability of collusion is 2−w2^{-w}.

原文
存档评论2 条抓取于