#abc217f. F - Make Pair

F - Make Pair

Score : 500500 points

问题描述

2N2N名学生站成一排,从左至右依次编号为11, 22, \ldots, 2N2N。对于任意两个学生,他们要么关系好要么关系差。具体来说,对于每个1iM1\leq i\leq M,学生AiA_i和学生BiB_i关系好;其余的任意两个学生的组合则关系差。

老师打算进行以下操作NN次来组成NN对关系好的学生。

  • 选择一对相邻且关系好的学生,将他们配对并从队伍中移除。
  • 若移除的学生不在队伍的两端,则填补空位,使得原来在被移除学生左右两侧的学生变为相邻。

求出执行这个操作NN次的不同方法数,结果对998244353998244353取模。若存在1iN1\leq i\leq N,使得两种执行方式在第ii次操作中所选的学生对不同,则认为这两种执行方式是不同的。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are 2N2N students standing in a row, numbered 11, 22, \ldots, 2N2N from left to right. For all pairs of two students, they are on good or bad terms. Specifically, for each 1iM1\leq i\leq M, Student AiA_i and Student BiB_i are on good terms; for the remaining pairs of two students, they are on bad terms.

The teacher is going to do the following operation NN times to form NN pairs of two students.

  • Choose two adjacent students who are on good terms, pair them, and remove them from the row.
  • If the removed students were not at an end of the row, close up the gap so that the two students who were to the left and right of the removed students are now adjacent.

Find the number, modulo 998244353998244353, of possible ways to do the operation NN times. Two ways to do the operation NN times are considered different when there exists 1iN1\leq i\leq N such that the pair of students chosen in the ii-th operation is different in those two ways.

Constraints

  • 1N2001 \leq N \leq 200
  • 0MN(2N1)0 \leq M \leq N(2N-1)
  • 1Ai<Bi2N1 \leq A_i < B_i \leq 2N
  • All pairs (Ai,Bi)(A_i, B_i) are distinct.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

A1A_1 B1B_1

A2A_2 B2B_2

\vdots

AMA_M BMB_M

Output

Print the number of possible ways to complete the procedure, modulo 998244353998244353.

Sample Input 1

2 3
1 2
1 4
2 3

Sample Output 1

1

The only way to complete the procedure is to choose Students 22 and 33 in the first and Students 11 and 44 in the second. If Students 11 and 22 are chosen in the first operation, Students 33 and 44 will remain, who are on bad terms and thus cannot be paired in the second operation.
Thus, you should print 11.

Sample Input 2

2 2
1 2
3 4

Sample Output 2

2

There are two ways to complete the procedure: one way is to choose Students 11 and 22 in the first operation and Students 33 and 44 in the second, and the other way is to choose Students 33 and 44 in the first operation and Students 11 and 22 in the second. Note that these two ways are distinguished.

Sample Input 3

2 2
1 3
2 4

Sample Output 3

0

Since no pair can be chosen in the first operation, there is no way to complete the procedure, so you should print 00.

update @ 2024/3/10 09:37:25