QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#3707. 奇数折扣

統計

在 ICPCCamp 的商店里,有 $n$ 件商品出售,并提供 $m$ 个捆绑包。 第 $i$ 个捆绑包由 $c_i$ 和 $k_i$ 个不同的整数 $a_{i,1}, a_{i,2}, \dots, a_{i,k_i}$ 描述。这意味着如果购买的商品中,编号为 $a_{i,1}, a_{i,2}, \dots, a_{i,k_i}$ 的商品数量之和为奇数,则可以获得 $c_i$ 美元的折扣。捆绑包可以组合使用。

Bobo 想要购买一个非空的商品子集。显然,他有 $(2^n - 1)$ 种不同的购买方案。 求 $(d_1^2 + d_2^2 + \dots + d_{2^n-1}^2)$ 对 $(10^9 + 7)$ 取模的结果,其中 $d_i$ 是第 $i$ 种方案获得的折扣总额。

输入格式

第一行包含两个整数 $n, m$ ($1 \le n \le 20, 1 \le m \le 10^5$)。 接下来的 $m$ 行,第 $i$ 行包含整数 $c_i, k_i$,随后是 $k_i$ 个整数 $a_{i,1}, a_{i,2}, \dots, a_{i,k_i}$ ($1 \le c_i \le 10^4, 1 \le a_{i,1}, a_{i,2}, \dots, a_{i,k_i} \le n$)。

输出格式

输出一个整数,表示 $(d_1^2 + d_2^2 + \dots + d_{2^n-1}^2)$ 对 $(10^9 + 7)$ 取模的结果。

样例

样例输入 1

2 2
1 1 1
2 2 1 2

样例输出 1

14

样例输入 2

1 1
1 1 1

样例输出 2

1

说明

在第一个样例中,Bobo 有 3 种购买方案: 他购买第一件商品,并使用两个捆绑包。 他购买第二件商品,并仅使用第二个捆绑包。 * 他购买两件商品,并使用第一个捆绑包。

因此,$d_1 = 3, d_2 = 2, d_3 = 1$,且 $d_1^2 + d_2^2 + d_3^2 = 14$。

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.