Universal Cup Judging System

Universal Cup

Límite de tiempo: 5.0 s Límite de memoria: 512 MB Puntuación total: 100 Hackeable ✓
Estadísticas

定义一个在 $V = \{0, 1, \dots, 2^{64} - 1\}$ 上的闭函数 $f$ 为单轮哈希函数,当且仅当它具有以下标准形式:

$$f(X) = B \oplus \bigoplus_{j=1}^{m} ((X \ll s_j) \circ_j A_j)$$

其中:

  • $A_j, B \in V$;
  • $0 \le m \le 64$,$0 \le s_j \le 63$ 且所有 $s_j$ 互不相同;
  • $\oplus$ 表示按位异或运算,$\ll$ 表示循环左移运算($V$ 上的循环左移定义为将 64 位无符号二进制表示进行循环左移),$\circ_j$ 表示按位或运算(记作 $\vee$)或按位与运算(记作 $\wedge$)。

给定 $N$ 个单轮哈希函数 $f_1, f_2, \dots, f_N$ 和 $Q$ 次操作,操作分为以下两种类型:

  • 给定 $l, r, x$,计算 $f_r(\dots(f_{l+1}(f_l(x)))\dots)$ 的值;
  • 给定 $l$,将 $f_l$ 修改为一个新的单轮哈希函数。

考虑到修改单轮哈希函数会使大量快速哈希转换的结果失效,保证此类修改操作不超过 $C$ 次。

输入格式

第一行包含三个非负整数 $N, Q, C$,分别表示需要维护的单轮哈希函数数量、操作次数以及修改单轮哈希函数的操作次数。保证 $1 \le N, Q \le 20,000$,$0 \le C \le 400$ 且 $C < Q$。

从第二行到第 $(N+1)$ 行,第 $(i+1)$ 行描述了 $f_i$ 的初始参数:

  • 每行第一个非负整数 $m$ 表示 $f_i$ 标准形式中异或和的项数。保证 $0 \le m \le 64$。
  • 接下来依次输入 $3m$ 个非负整数,其中第 $(3j-2)$ 个、第 $(3j-1)$ 个和第 $3j$ 个整数分别为 $s_j, o_j, A_j$,分别表示 $X$ 在第 $j$ 项异或和中循环左移的位数、第 $j$ 项中按位运算的类型($o_j=0$ 对应按位或运算,$o_j=1$ 对应按位与运算)以及第 $j$ 项中按位运算的常数项。保证 $0 \le s_j \le 63$ 且在同一个单轮哈希函数中 $s_j$ 的值互不相同,$0 \le o_j \le 1$,$0 \le A_j < 2^{64}$。
  • 每行最后一个数是一个非负整数 $B$,表示标准形式外层的常数项。保证 $0 \le B < 2^{64}$。

从第 $(N+1)$ 行到第 $(N+Q+1)$ 行,第 $(N+i+1)$ 行描述了第 $i$ 次操作。

  • 每行开头是一个非负整数 $op$,表示操作类型。
  • 若 $op = 0$,表示进行一次快速哈希转换操作。后面跟着三个非负整数 $l, r, x$,分别表示起始位置、结束位置和快速哈希转换的初始值。保证 $1 \le l \le r \le N$,$0 \le x < 2^{64}$。
  • 若 $op = 1$,表示修改某个单轮哈希函数。首先输入一个整数 $l$,表示要修改的单轮哈希函数的编号。然后依次输入若干整数来描述修改后的 $f_l$。描述新单轮哈希函数的格式与描述每个函数初始参数的格式相同。保证 $1 \le l \le N$。

输出格式

对于每种类型的第一种操作,输出一行,包含一个整数,表示答案。

样例

样例输入 1

3 5 1
1 4 0 0 51966
1 60 0 0 0
1 0 0 16 15
0 1 1 771
0 2 2 32368
0 3 3 0
1 2 2 0 0 15 61 1 4095 46681
0 1 3 2023

样例输出 1

64206
2023
31
1112

说明

对于第一个样例:

3 个单轮哈希函数的初始参数为:

  • $f_1(X) = (X \ll 4) \oplus 51996$(其中 51996 的十六进制表示为 ‘0xCAFE’);
  • $f_2(X) = X \ll 60$;
  • $f_3(X) = (X \vee 16) \oplus 15$(其中 16 和 15 的十六进制表示分别为 ‘0x0010’ 和 ‘0x000F’)。

第一次操作是进行快速哈希转换。对 771 (‘0x0303’) 进行快速哈希转换的结果为 $f_1(771) = (771 \ll 4) \oplus 51996 = 64206$ (‘0xFACE’)。

第二次操作是进行快速哈希转换。对 32368 (‘0x7E70’) 进行快速哈希转换的结果为 $f_2(32368) = 32368 \ll 60 = 2023$ (‘0x07E7’)。

第三次操作是进行快速哈希转换。对 0 (‘0x0000’) 进行快速哈希转换的结果为 $f_3(0) = (0 \vee 16) \oplus 15 = 31$ (‘0x001F’)。

第四次操作是修改 $f_2$。修改后,$f_2(X) = (X \vee 15) \oplus ((X \ll 61) \wedge 4095) \oplus 46681$(其中 4095 和 46681 的十六进制表示分别为 ‘0x0FFF’ 和 ‘0xB659’)。

第五次操作是进行快速哈希转换。对于初始值 2023 (‘0x07E7’),由于 $f_1(2023) = 46222$ (‘0xB48E’),$f_2(46222) = 1095$ (‘0x0447’),且 $f_3(1095) = 1112$ (‘0x0458’),因此快速哈希转换的结果为 1112。

请注意输入输出效率对程序运行时间的影响。

在样例说明中,所有十六进制表示均补齐至 4 位,但这并不意味着输入数字不超过 65535。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.