Logo
(追記) (追記ここまで)

21102번 - Local Maxima 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 512 MB42272060.606%

문제

Given an $n \times m$ integer matrix $A,ドル a local maximum of $A$ is a location $(i, j)$ (1ドル \le i \le n$ and 1ドル \le j \le m$) such that $A_{i, j}$ is no smaller than any other integer on the $i$-th row or on the $j$-th column.

For example, in the 3ドル \times 3$ matrix $$ \begin{bmatrix} 2 & 5 & 4 \\ 2 & 1 & 6 \\ 2 & 2 & 2 \end{bmatrix}\text{,} $$ there are three local maxima: locations $(1, 2),ドル $(2, 3),ドル and $(3, 1)$ with values 5ドル,ドル 6ドル,ドル and 2ドル,ドル repectively.

An $n \times m$ integer matrix $A$ is good if and only if it satisfies the following two conditions:

  • There is exactly one local maximum in $A$.
  • Each integer from 1ドル$ to $n \times m$ occurs exactly once in $A$.

Given $n,ドル $m,ドル and a prime number $P,ドル your task is to count the number of good matrices of size $n \times m$ modulo $P$.

입력

The first line contains three integers, $n,ドル $m,ドル and $P,ドル where 1ドル \le n, m \le 3000$ and 10ドル^8 \le P \le 10^9 + 7$. It is guaranteed that $P$ is prime.

출력

Output a single line with a single integer: the number of good matrices modulo $P$.

제한

예제 입력 1

2 2 1000000007

예제 출력 1

16

예제 입력 2

4 3 1000000007

예제 출력 2

95800320

예제 입력 3

100 100 998244353

예제 출력 3

848530760

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 6: PKU Contest 2 H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /