QOJ.ac

QOJ

Time Limit: 4 s Memory Limit: 512 MB Total points: 100

#977. Cực đại địa phương

Statistics

Cho một ma trận số nguyên $n \times m$ là $A$, một cực đại địa phương (local maximum) của $A$ là một vị trí $(i, j)$ ($1 \le i \le n$ và $1 \le j \le m$) sao cho $A_{i,j}$ không nhỏ hơn bất kỳ số nguyên nào khác trên hàng thứ $i$ hoặc cột thứ $j$.

Ví dụ, trong ma trận $3 \times 3$ $$\begin{bmatrix} 2 & 5 & 4 \\ 2 & 1 & 6 \\ 2 & 2 & 2 \end{bmatrix},$$ có ba cực đại địa phương: các vị trí $(1, 2)$, $(2, 3)$ và $(3, 1)$ với các giá trị lần lượt là $5$, $6$ và $2$.

Một ma trận số nguyên $n \times m$ $A$ được gọi là tốt (good) nếu và chỉ nếu nó thỏa mãn hai điều kiện sau: Có đúng một cực đại địa phương trong $A$. Mỗi số nguyên từ $1$ đến $n \times m$ xuất hiện đúng một lần trong $A$.

Cho $n$, $m$ và một số nguyên tố $P$, nhiệm vụ của bạn là đếm số lượng ma trận tốt kích thước $n \times m$ theo modulo $P$.

Dữ liệu vào

Dòng đầu tiên chứa ba số nguyên $n$, $m$ và $P$, trong đó $1 \le n, m \le 3000$ và $10^8 \le P \le 10^9 + 7$. Đảm bảo rằng $P$ là số nguyên tố.

Dữ liệu ra

In ra một dòng duy nhất với một số nguyên duy nhất: số lượng ma trận tốt theo modulo $P$.

Ví dụ

Dữ liệu vào 1

2 2 1000000007

Dữ liệu ra 1

16

Dữ liệu vào 2

4 3 1000000007

Dữ liệu ra 2

95800320

Dữ liệu vào 3

100 100 998244353

Dữ liệu ra 3

848530760

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#517Editorial Open集训队作业 解题报告 by 全柏锋Qingyu2026-01-02 21:36:43 Download

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.