「WHOI-2」D&D

Luogu
IDLGP8434
Time1000ms
Memory128MB
DifficultyP6
动态规划 DP搜索数学二分洛谷原创O2优化位运算双指针 two-pointer
给定**不重**集合 $A$,定义其 _装饰子集_ $$f(A)=\{a\in A|\forall b\in A-\{a\},a|b\not= b \}$$ 这里的 $\texttt{“|”}$ 表示按位或;这里 $b\in A-\{a\}$ 表示 $b\in A$ 且 $b\not=a$。 miku 有一个长度为 $n$ 的正整数序列 $a_i$。你要给这个序列连续地划分为若干个(至少一个)连续子串。要求这些连续子串元素所组成的**不重集合**的 _装饰子集_ 相同。 求方案数对 $10^9+7$ 取模。 ## Input 第一行一个正整数表示 $n$。 接下来长度为 $n$ 的正整数序列表示 $a_i$。 ## Output 一行一个正整数表示答案。 [samples] ## Background 有没有发现少了什么? 我们的 miku 决定出门逛街了。但是好巧不巧的就是她家里的装饰物少的可怜,并且只有一些数字可以作为装饰。 但是 miku 发现如果有若干个装饰物组成的数集 $A$,那么 $A$ 的子集 $f(A)$ 是最好看的(尽管不知道为什么)。所以就有了这道题。 但是因为看到了标题,所以聪明的你应该知道 miku 要去哪里了(误)。 ## Note **【样例#1解释】** 可以证明,两种方法分别是: $$[1,2,3,4,5,5,4,3,2,1]$$ $$[1,2,3,4,5],[5,4,3,2,1]$$ 这里三个子集所组成的不重集合都是 $\{1,2,3,4,5\}$。它们的装饰子集都是 $\{3,5\}$。具体说明如下: - $1:1|3=3$,故不属于。 - $2:2|3=3$,故不属于。 - $3:3|1=3,3|2=3,3|4=7,3|5=7$,故属于。 - $4:4|5=5$,故不属于。 - $5:5|1=5,5|2=7,5|3=7,5|4=5$,故属于。 --- **本题采用捆绑测试** - $\text{subtask1(5pts)}:n\leq10$。 - $\text{subtask2(10pts)}:a_i\leq7$。 - $\text{subtask3(20pts)}:a_i=2^a+2^b$。其中 $a\not = b$。 - $\text{subtask4(20pts)}:a_i=2^a+2^b$。其中不保证 $a\not =b$。 - $\text{subtask5(10pts)}:$ 保证 $a_i$ 随机生成。 - $\text{subtask6(35pts)}:$ 无特殊限制。时限为 $3s$。 对于 $100\%$ 的数据,保证 $1\leq n\leq 3\times10^6,0\leq a_i\leq2\times 10^6$。
Samples
Input #1
10
1 2 3 4 5 5 4 3 2 1
Output #1
2
Input #2
9
1 2 2 1 1 1 2 2 1
Output #2
16
API Response (JSON)
{
  "problem": {
    "name": "「WHOI-2」D&D",
    "description": {
      "content": "给定**不重**集合 $A$,定义其 _装饰子集_  $$f(A)=\\{a\\in A|\\forall b\\in A-\\{a\\},a|b\\not= b \\}$$ 这里的 $\\texttt{“|”}$ 表示按位或;这里 $b\\in A-\\{a\\}$ 表示 $b\\in A$ 且 $b\\not=a$。 miku 有一个长度为 $n$ 的正整数序列 $a_i$。你要给这个序列连续地划分为若干个(至少一",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 131072
    },
    "difficulty": {
      "LuoguStyle": "P6"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP8434"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给定**不重**集合 $A$,定义其 _装饰子集_ \n\n$$f(A)=\\{a\\in A|\\forall b\\in A-\\{a\\},a|b\\not= b \\}$$\n\n这里的 $\\texttt{“|”}$ 表示按位或;这里 $b\\in A-\\{a\\}$ 表示 $b\\in A$ 且 $b\\not=a$。\n\nmiku 有一个长度为 $n$ 的正整数序列 $a_i$。你要给这个序列连续地划分为若干个(至少一...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments