QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#3086. 邊子集

统计

給定整數 $A$、$B$ 以及一個包含 $N$ 個頂點與 $M$ 條邊的簡單無向圖。頂點編號由 $1$ 至 $N$,邊編號由 $1$ 至 $M$。第 $i$ 條邊連接頂點 $U_i$ 與 $V_i$。在此保證 $V_i - U_i = A$ 或 $V_i - U_i = B$。

請計算該圖中匹配(matching)的數量,並對 $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.