im in a compeittive programming competition help me get better rank , its crucial Alice…
- User
im in a compeittive programming competition help me get better rank , its crucial Alice has a number N N and she wants to build a table T T with 2 2 rows and N N columns. The table T T should respect the following constraints:
Each number from 1 1 to 2 ∗ N 2∗N appears in T T exactly once The numbers from each row should be in increasing order: T i , j < T i , j + 1 T i,j <T i,j+1 for all 1 ≤ i ≤ 2 1≤i≤2, 1 ≤ j < N 1≤j<N The numbers from each column should also be in increasing order: T 1 , j < T 2 , j T 1,j <T 2,j for all 1 ≤ j ≤ N 1≤j≤N Additionally, for each number from 1 1 to 2 ∗ N 2∗N Alice knows whether she wants to use that particular number on the first row of T T, on the second row of T T, or both. Alice has two disjoint arrays A A and B B, where:
The numbers from A A should only be used on the first row The numbers from B B should only be used on the second row The numbers that don't appear in either A A or B B have no restrictions Print the number of valid ways to fill the table T T modulo 998244353 998244353.
Standard Input The first line of input contains an integer N N.
The second line contains an integer X X and then X X distinct integers representing the elements of A A.
The third line contains an integer Y Y and then Y Y distinct integers representing the elements of B B.
Standard Output Output one integer — the number of valid ways to fill the 2 × N 2×N table modulo 998244353 998244353.
Constraints and Notes 1 ≤ N ≤ 2000 1≤N≤2000 0 ≤ X , Y ≤ N 0≤X,Y≤N Sets A A and B B are disjoint and contain distinct integers from 1 1 to 2 ∗ N 2∗N Input Output Explanation 4 2 5 2 3 6 4 8 2 The two possible arrangements are:
1 2 3 5 4 6 7 8 1 4
2 6
3 7
5 8
and
1 2 5 7 3 4 6 8 1 3
2 4
5 6
7 8
find a c++ solution and xplain it well
- Assistant