QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#3086. 边子集

統計

给定整数 $A, B$ 以及一个包含 $N$ 个顶点和 $M$ 条边的简单无向图。顶点编号为 $1$ 到 $N$,边编号为 $1$ 到 $M$。第 $i$ 条边连接顶点 $U_i$ 和 $V_i$。题目保证对于每一条边,满足 $V_i - U_i = A$ 或 $V_i - U_i = B$。

求该图的匹配数量,结果对 $998244353$ 取模。注意,图的匹配是指边的子集,且这些边所连接的端点互不相同。

输入格式

第一行包含整数 $N$ ($3 \le N \le 200$),$M$ ($1 \le M \le 400$),$A$ 和 $B$ ($1 \le A < B \le N - 1$)。

接下来的 $M$ 行描述边。第 $i$ 行包含整数 $U_i$ 和 $V_i$ ($1 \le U_i < V_i \le N$,$V_i - U_i = A$ 或 $V_i - U_i = B$)。图中不存在自环或重边。

输出格式

输出答案。

样例

样例输入 1

4 3 1 2
1 2
1 3
3 4

样例输出 1

5

样例输入 2

10 14 2 4
5 7
7 9
2 6
6 8
1 5
3 7
4 8
1 3
4 6
8 10
3 5
5 9
2 4
6 10

样例输出 2

225

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1018EditorialOpen题解Qiuly2026-02-14 02:06:51View

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.