QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#10306. 黄焖鸡

统计

题目背景

小 F 喜欢吃黄焖鸡。但是有一天他发现,有神秘人在他去往食堂的路上设置了无法跨过的障碍;只有解决下面的问题,障碍才能消失。

题目描述

对于一个正整数序列 $a$,定义 $a$ 的最大权独立集的权值为从 $a$ 中选择若干不相邻的数,选出的数的和的最大值。(相邻的定义:设 $n$ 为 $a$ 的长度,则对于 $1\le i\lt n$,位置 $i$ 和位置 $i+1$ 相邻,其它均不相邻)

如果 $a$ 的最大权独立集权值的两倍刚好是 $a$ 中所有数的和,就说 $a$ 是坏的;否则就说 $a$ 是好的。

若正整数序列 $a$ 的任何子区间都是好的,就说 $a$ 是极好的。(子区间的定义:设 $a$ 的长度为 $n$,则 $\forall 1\le l\le r\le n$,$[a_l,a_{l+1},\dots,a_r]$ 称为 $a$ 的一个子区间)

给定 $n,m$ 和 $n$ 个正整数集合 $A_1\sim A_n$,$n$ 表示 $a$ 的长度,集合中的数都属于 $[1,m]$。问:如果对于每个 $i$,$a_i$ 都可以在 $A_i$ 中任取,有多少种方案可以使得 $a$ 是极好的。答案对 $998244353$ 取模。

输入格式

从标准输入读入数据。

输入的第一行是两个正整数 $n,m$,用一个空格隔开。

接下来 $n$ 行,第 $i\ (1\le i\le n)$ 行有 $m$ 个字符,每个字符都是 0 或 1,第 $j\ (1\le j\le m)$ 个字符如果是 1,表示 $j\in A_i$,否则表示 $j\notin A_i$。字符之间用一个空格隔开。

输出格式

输出到标准输出。

输出答案模 $998244353$ 的值。

样例数据

样例 1 输入

3 3
1 1 1
1 0 1
1 1 0

样例 1 输出

4

样例 1 解释

本样例中,$A_1=\{1,2,3\},A_2=\{1,3\},A_3=\{1,2\}$,极好的序列有以下几种:

  • $[1,3,1]$
  • $[2,1,2]$
  • $[2,3,2]$
  • $[3,1,2]$

子任务

所有数据均满足:$1\le n\le 200,1\le m\le 19$。

子任务 $n$ $m$ 特殊性质 分数
1 $\le 10$ $\le 5$ $7$
2 $\le 200$ $\le 3$ $3$
3 $\le 4$ $\forall 1\le i\le n,\forall 1\le j\le m$,都有 $j\in A_i$ $5$
4 $\le 4$ $20$
5 $\le 5$ $10$
6 $\le 6$ $5$
7 $\le 7$ $10$
8 $\le 12$ $5$
9 $\le 16$ $15$
10 $\le 19$ $20$
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.