問題一覧 > 通常問題

No.803 Very Limited Xor Subset

レベル : / AI推定難易度 : 1800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 73
作問者 : tempura_pp / テスター : heno239
お気に入りにしたユーザー ProblemId : 2818 / 自分の提出
問題文最終更新日: 2019-03-17 20:14:43
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 208 (順位表) の他の問題:

Problem Statement

heno has an integer sequence $A_1,\ A_2,\cdots ,\ A_N$ of length $N$ and an integer $X$. heno was thinking about the following problem.

"Choose 0 or more integers from $A_1,\ A_2,\cdots ,A_N$ and compute the bitwise XOR of all the chosen integers. How many ways are there to choose the integers so that the result is $X$?"

Since heno loves XOR, this problem was a little too easy for him. So he decided to add $M$ more conditions, each expressed in one of the following forms.

  • $0\ l\ r\ $: The number of integers chosen from $A_l,\ A_{l+1},\cdots ,\ A_r$ is even (it may be 0).
  • $1\ l\ r\ $: The number of integers chosen from $A_l,\ A_{l+1},\cdots ,\ A_r$ is odd.
Find the number of ways to choose 0 or more integers so that all $M$ conditions are satisfied and their XOR is $X$, modulo $10^9+7$. Here, the XOR when 0 integers are chosen is defined to be 0.

Input

$N\ M\ X$
$A_1 A_2 \cdots A_N$
$type_1\ l_1\ r_1$
$type_2\ l_2\ r_2$
$\vdots$
$type_M\ l_M\ r_M$

  • $1\le N \le 300$
  • $0\le M \le min(300,\frac{N(N+1)}{2})$
  • $0\le X,\ A_i \le 10^9$
  • $type_i\ =\ 0,\ 1$
  • $1 \le l_i \le r_i\le N$
  • If $i \neq j$, then $(l_i,\ r_i)\neq (l_j,\ r_j)$
  • All input values are integers

Output

Print on one line the number of ways to choose integers satisfying the conditions, modulo $10^9+7$.

Sample

Sample 1
Input
4 2 3
1 1 2 2
0 2 3
0 1 4
Output
2

The 2 choices satisfying all the conditions are $\{a_1,\ a_4\},\ \{a_2,\ a_3\}$.

Sample 2
Input
4 1 3
1 1 2 2
1 1 4
Output
0

It is impossible to choose an odd number of integers from the whole sequence and also make the XOR equal to 3.

Sample 3
Input
7 3 2
1 2 3 4 5 6 7
0 2 4
0 5 6
1 2 6
Output
0

Sample 4
Input
15 5 12582921
12582923 10485775 5242888 9437185 3145743 10485768 13631489 2097158 11534339 15 14680065 6291461 7340039 10485764 7340035
1 4 11
0 5 6
0 13 15
0 1 10
0 8 11
Output
8

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。