QOJ.ac

QOJ

时间限制: 3.0 s 内存限制: 256 MB 总分: 100

#11730. 二进制字符串

统计

Rikka 有一个长度为 $n$ 的二进制字符串。

我们不知道这个字符串的具体内容。但我们确定的是,对于每个 $i \in \{1, 2, \dots, m\}$,以下两个条件中至少有一个成立:“前 $y_i$ 位中恰好有 $x_i$ 个 1”或者“后 $x_i$ 位中恰好有 $y_i$ 个 1”。

请计算满足条件的二进制字符串的数量,结果对 $998\,244\,353$ 取模。

输入格式

第一行包含一个整数 $T$,表示测试用例的数量 ($1 \le T \le 5$)。

对于每个测试用例,第一行包含两个整数 $n$ 和 $m$ ($1 \le n \le 5000, 0 \le m \le 1000$)。

接下来的 $m$ 行中,第 $i$ 行包含两个整数 $x_i$ 和 $y_i$ ($0 \le x_i, y_i \le n, x_i \neq 0$ 或 $y_i \neq 0$)。

输出格式

对于每个测试用例,输出一个整数,表示满足约束条件的二进制字符串的数量,结果对 $998\,244\,353$ 取模。

样例

样例输入 1

2
3 1
2 1
5 3
1 3
4 2
3 1

样例输出 1

4
2

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.