#P7717. 「EZEC-10」序列

    ID: 8243 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP2021O2优化深度优先搜索 DFS数位 DP图论建模字典树 Trie位运算

「EZEC-10」序列

Background

Accurate analytic characterization should be the first breakthrough to try.

— command_block, "Pre-exam Tips"

Problem Description

How many different sequences aa are there that satisfy:

  1. The length of aa is nn.
  2. All elements in aa are non-negative integers not greater than kk.
  3. There are mm constraints of the form (xi,yi,zi)(x_i, y_i, z_i) with xi<yix_i < y_i. Each constraint means axiayi=zia_{x_i} \oplus a_{y_i} = z_i (\oplus denotes the bitwise XOR operation).

Two sequences are the same if and only if all their elements are the same.

Please output the result modulo 109+710^9+7 .

Input Format

The input has m+1m+1 lines:

  • The first line contains three integers n,m,kn, m, k.
  • The next mm lines each contain three integers xi,yi,zix_i, y_i, z_i.

Output Format

Output one line containing the result modulo 109+710^9+7.

3 1 2
1 2 1
6
5 1 12
1 2 3

26364

Hint

[Sample 11 Explanation]

There are 66 sequences: $\{0,1,0\},\{0,1,1\},\{0,1,2\},\{1,0,0\},\{1,0,1\},\{1,0,2\}$.

[Data Scale and Conventions]

This problem uses bundled testdata.

  • Subtask 1 (1 point): n=1n=1.
  • Subtask 2 (5 points): m=0m=0.
  • Subtask 3 (15 points): n,m,k5n,m,k\le 5.
  • Subtask 4 (10 points): zi=0z_i=0.
  • Subtask 5 (20 points): k16k\le 16.
  • Subtask 6 (2 points): testdata is random.
  • Subtask 7 (47 points): no special constraints.

For 100%100\% of the testdata: 1n5×1051 \leq n \leq 5 \times 10^5, 0m5×1050 \le m \le 5 \times 10^5, 0zi<2300 \le z_i<2^{30}, 1k<2301 \leq k< 2^{30}, 1xi,yin1\le x_i,y_i\le n.

[Hint]

If you do not know what XOR is, please click here

Translated by ChatGPT 5