問題一覧 > 通常問題

No.1426 Got a Covered OR

レベル : / AI推定難易度 : 1800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 78
作問者 : 👑 箱星 / テスター : nok0
お気に入りにしたユーザー ProblemId : 5286 / 自分の提出
問題文最終更新日: 2022-04-25 23:58:40
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 286 (順位表) の他の問題:

Story

Legend has it that in the ancient Kingdom of Yukiko, a sequence of positive integers $A_1,A_2,\ldots,A_N$ of length $N$ was treated as a sacred sequence. Legend also has it that the kingdom had $N$ stone monuments, and that the value of $A_1 \ \mathrm{OR} \ A_2 \ \mathrm{OR} \ \cdots \ \mathrm{OR} \ A_i$ was engraved on the $i$-th monument. However, with the fall of the kingdom, the information about what the sacred sequence $A_1,A_2,\ldots,A_N$ was has been lost.

Investigator Koboshi has discovered some of the $N$ monuments. The value $B_i$ was engraved on the $i$-th monument. $B_i=-1$ means that the $i$-th monument was not discovered. It is guaranteed that $B_N\ne -1$ (that is, the $N$-th monument was discovered).

Koboshi tried to find how many sequences are possible as the sacred sequence $A_1,A_2,\ldots,A_N$, but could not do so. Therefore, Koboshi has asked you to solve the following problem.

Problem Statement

Find the number of sequences of positive integers $A_1,A_2,\ldots,A_N$ that satisfy the following condition.

  • For each $i \ (i=1,2,\ldots,N)$ such that $B_i\ne -1$, $B_i$ is equal to $A_1 \ \mathrm{OR} \ A_2 \ \mathrm{OR} \ \cdots \ \mathrm{OR} \ A_i$.

Since the answer can be very large, find it modulo $10^9+7$. It is guaranteed that the answer is finite.

$a \ \mathrm{OR} \ b$ denotes the bitwise OR of $a$ and $b$.

Input

$N$
$B_1$ $B_2$ $\ldots$ $B_N$
  • All inputs are integers.
  • $1\le N\le 10^5$
  • $1\le B_i\lt 2^{30}$ or $B_i=-1$
  • $B_N\ne -1$

Output

Find the number of possible sequences of positive integers $A_1,A_2,\ldots,A_N$, and output it modulo $10^9+7$.

Sample

Sample 1
Input
3
1 -1 3
Output
8

There are $8$ sequences: $(A_1,A_2,A_3)=(1,1,2),(1,1,3),(1,2,1),(1,2,2),(1,2,3),(1,3,1),(1,3,2),(1,3,3)$.

Sample 2
Input
5
5 -1 -1 -1 4
Output
0

There may be no such sequences.

Sample 3
Input
7
-1 -1 -1 -1 -1 -1 7777777
Output
281468948

Output the answer modulo $10^9+7$.

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