#P10681. [COTS 2024] 奇偶矩阵 Tablica

    ID: 12176 远端评测题 1000ms 1024MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划 DP递推2024O2优化生成函数线性递推COCI(克罗地亚)

[COTS 2024] 奇偶矩阵 Tablica

Background

Translated from Izborne Pripreme 2024 (Croatian IOI/CEOI Team Selection) D1T2. 1s,1G\texttt{1s,1G}。

Problem Description

Consider an N×MN \times M matrix AA that contains only 00 and 11.

We call a matrix good if it satisfies the following conditions:

  • 1iN\forall 1\le i\le N, j=1MAi,j{1,2}\displaystyle \sum_{j=1}^M A_{i,j}\in \{1,2\};
  • 1jM\forall 1\le j\le M, i=1NAi,j{1,2}\displaystyle \sum_{i=1}^N A_{i,j}\in \{1,2\}.

Find the number of good matrices with NN rows and MM columns, modulo (109+7)(10^9+7).

Input Format

The input consists of one line with two positive integers, N,MN, M.

Output Format

Output one line with one integer, the result modulo (109+7)(10^9+7).

2 2
7
3 3
102
15 20
415131258

Hint

Sample Explanation

Sample 11 is explained as shown in the figure.

Constraints

For 100%100\% of the testdata, 1N,M30001\le N,M\le 3\, 000.

Subtask ID Score Constraints
11 1010 N,M6N, M \leq 6
22 1818 N,M50N, M \leq 50
33 3131 N,M200N, M \leq 200
44 4141 No additional constraints

Translated by ChatGPT 5